Advanced Search

Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Shortening HTML with Javascript

  1. #1
    Join Date
    Dec 2006
    Posts
    42
    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-->

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    What do you mean by "shorten HTML"?

  3. #3
    Join Date
    Dec 2006
    Posts
    42
    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...
    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...

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 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.

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    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!

  6. #6
    Join Date
    Dec 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    What do you mean by Sever Side?

  7. #7
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Server side would be by using PHP, ASP or some other type of programming language on your server.

  8. #8
    Join Date
    Dec 2006
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    oh. Well I don't know PHP or ASP. So...I can't do it...

  9. #9
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 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.
    - Mike

  10. #10
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •