Go Back   Dynamic Drive Forums > General Coding > JavaScript
Search Dynamic Drive Forums:

Reply
 
Thread Tools Search this Thread
  #1  
Old 02-24-2007, 12:55 AM
Agent Moose Agent Moose is offline
Junior Coders
 
Join Date: Dec 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default Shortening HTML with Javascript

I know it is possible, but I don't know how to shorten HTML with JS. Anyone have any ideas for my following code...

Code:
<!--MC Radio V2-->
<script type="text/javascript" src="http://www.geocities.com/yort1223/MCRV2/HideShow.js">
</script>
<a title="Show Tables" href="javascript:toggleDisplay('table1')"><b><center>[Show/Hide MC Radio]</center></b>
<div style="display:none;" id=table1>
<div class="tableborder"> <div class='maintitle' align='left'>MC Radio V2</a></div> <table border="0" cellspacing="1" cellpadding="4"> <tr> <th align="center" width="23%" class='titlemedium'>Station</th> <th align="center" width="32%" class='titlemedium'>Description</th> <th align="center" width="20%" class='titlemedium'><center>Genre</center></th> </tr> <tr> <td class="row4" align="center">
<b>Listen to </b><form name="form1">
<select name="station" size="1" onChange="displaydesc(document.form1.station, description, genre, 'textcontainer1')">
<option selected value="http://www.1club.fm/clubfm_media/v42.aspx?station=activex" target="newwin">Active Radio X</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=modernrock" target="newwin">Modern Rock</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=classicrock" target="newwin">102 Rock</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=hairband">Hair Band Rock</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=classicalt-dude" target="newwin">Alternative Rock</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=clubuk" target="newwin">House of Trance</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=techno" target="newwin">Techno Club</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=harddance" target="newwin"> Gruvsonic Hard Dance</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=trance" target="newwin">Trance</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=rnb" target="newwin">R&B Hits</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=power" target="newwin">Old School Rap</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=breakbeat" target="newwin">70's Pop Hits</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=goapsy" target="newwin">80's Pop Hits</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=ibiza" target="newwin">90's Pop Hits</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=hitmusic" target="newwin">Channel 1</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=vradio" target="newwin">Variety Hits</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=vybe" target="newwin">70's Decade Hits</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=clubuk" target="newwin">80's Decade Hits</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=harddance" target="newwin">90's Decade Hits</option>
<option value="http://www.1club.fm/clubfm_media/v42.aspx?station=hkcountry" target="newwin">Kicker Country</option>
</select>
<input type="button" value="Listen"
onClick="jumptolink(document.form1.station)">
</form>
</a></td> <td class="row4">
<span id="textcontainer1" align="left" style="font:italic 13px Arial">
</span>
<script type="text/javascript" src="http://www.geocities.com/yort1223/MCRV2/description.js"></script>
<br /></td> <td class="row2" align="center">
<span id="textcontainer2" align="center" style="font:bold 13px Arial">
</span>
<script type="text/javascript" src="http://www.geocities.com/yort1223/MCRV2/genre.js"></script>
<script type="text/javascript" src="http://www.geocities.com/yort1223/MCRV2/main.js"></script>
</td></table>
<table border="0" cellspacing="1" cellpadding="4"> <tr> <th align="left" width="10%" height="5%" class='darkrow2'><a href="http://z11.invisionfree.com/MooseCreations" target="_blank">©</a> - Created By Agent Moose</th></tr></table>
</div><br></div>
</div><br></div>
<!--End MC Radio V2-->
Reply With Quote
  #2  
Old 02-24-2007, 01:04 AM
thetestingsite's Avatar
thetestingsite thetestingsite is online now
The Guy That Moderates
 
Join Date: Sep 2006
Location: St. George, UT
Posts: 2,795
Thanks: 3
Thanked 156 Times in 154 Posts
Default

What do you mean by "shorten HTML"?
Reply With Quote
  #3  
Old 02-24-2007, 01:14 AM
Agent Moose Agent Moose is offline
Junior Coders
 
Join Date: Dec 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Make it so that it is like this...

Code:
<script src="WWW.URLHERE.COM"></script>
Inside the URL will be something like this...
Quote:
document.write(<table>HTML HERE</table>
That is the easyest way I can put it.

The code above will be in URL part. Just like shortening JS. But with HTML...
Reply With Quote
  #4  
Old 02-24-2007, 01:23 AM
thetestingsite's Avatar
thetestingsite thetestingsite is online now
The Guy That Moderates
 
Join Date: Sep 2006
Location: St. George, UT
Posts: 2,795
Thanks: 3
Thanked 156 Times in 154 Posts
Default

Probably a better way to do this, but In the new js file type in this:

Code:
document.write('<html><title>This is a test</title></head><body></body></html>');
Then in the actual HTML document, type in:

Code:
<script type="text/javascript" src="newfile.js"></script>
Not tested, probably won't work, and don't even know if this is what you want to do. But Hope this helps.
Reply With Quote
  #5  
Old 02-24-2007, 01:30 AM
Twey's Avatar
Twey Twey is offline
Modtoreador
 
Join Date: Jun 2005
Location: 英国
Posts: 11,933
Thanks: 1
Thanked 180 Times in 172 Posts
Blog Entries: 2
Default

Will work roughly, but is not a good idea, since it introduces a dependency on Javascript, slows down the page loading time, and eliminates progressive rendering. Don't do it.

If you need to generate something like that, do it serverside. By no means use client-side scripting.
__________________
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Reply With Quote
  #6  
Old 02-24-2007, 01:31 AM
Agent Moose Agent Moose is offline
Junior Coders
 
Join Date: Dec 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What do you mean by Sever Side?
Reply With Quote
  #7  
Old 02-24-2007, 01:43 AM
thetestingsite's Avatar
thetestingsite thetestingsite is online now
The Guy That Moderates
 
Join Date: Sep 2006
Location: St. George, UT
Posts: 2,795
Thanks: 3
Thanked 156 Times in 154 Posts
Default

Server side would be by using PHP, ASP or some other type of programming language on your server.
Reply With Quote
  #8  
Old 02-24-2007, 01:45 AM
Agent Moose Agent Moose is offline
Junior Coders
 
Join Date: Dec 2006
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

oh. Well I don't know PHP or ASP. So...I can't do it...
Reply With Quote
  #9  
Old 02-24-2007, 02:25 AM
mburt's Avatar
mburt mburt is offline
Elite Coders
 
Join Date: Jul 2006
Location: Canada
Posts: 2,507
Thanks: 5
Thanked 22 Times in 22 Posts
Default

Also.. if you have the js file on your server it's still there somehow, no matter which way you put it. Just because it's in an external file doesn't mean the overall filesize will be smaller.
Some people can disable JavaScript if they want to with their browsers, and that's what makes it unreliable.
Reply With Quote
  #10  
Old 02-24-2007, 02:25 AM
tech_support's Avatar
tech_support tech_support is offline
Modarator Man.
 
Join Date: May 2006
Location: Sydney, Australia - Near the coast.
Posts: 2,011
Thanks: 0
Thanked 8 Times in 7 Posts
Default

Well, you could DOM it and put it in an external file.

//Also what mburt said ^^
__________________
Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
Currently: enjoying the early holidays :)
Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:05 PM.

Home - Contact Us - Archives - Link to DD - Top 

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.