Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Shortening HTML with Javascript

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

    Default

    I don't have a website. Just a forum from Invisionfree. I just learned something new...

    <script>
    test = "<table border='1'>"
    test += "</table>"
    </script>
    It creates a new table if I do sometihng like this...
    <script>
    document.write("'+test+'")
    </script>
    but it doesnt' work...

  2. #12
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    Code:
    document.write(test);
    As tech said, using the dom way is better. Look at an article about what it is/how to use it here:
    http://www.javascriptkit.com/domref/
    - Mike

  3. #13
    Join Date
    Feb 2007
    Location
    🌎
    Posts
    528
    Thanks
    10
    Thanked 10 Times in 10 Posts
    Blog Entries
    2

    Default

    Take that HTML, ant put it in an external HTML file, then use the following in forum:
    Code:
    <iframe src="html.html" frameborder="0">

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

    Default

    Quote Originally Posted by techno_race View Post
    Take that HTML, ant put it in an external HTML file, then use the following in forum:
    Code:
    <iframe src="html.html" frameborder="0">
    If I do that then it will be a diffrent CSS for the people who want to use my code...

    I have just made a test table thing with the code I did above and it worked. So I tried adding some stuff with it, and it didn't work...does anyone know why?

    Code:
    <script>
    mcsv1 = "<table width='100&#37;' id='userlinks' cellspacing='6'>"
    mcsv1 += "<tr>"
    mcsv1 += "<td class=guest><strong>MC Shop V1:</strong>  Please Log In to use the Shop.</td>"
    mcsv1 += "<td class=member><strong>MC Shop V1:</strong>  Which Item would you like?</td>"
    mcsv1 += "<form
    action='http://s11.invisionfree.com/MCtest/index.php?'
    method='post' name='REPLIER2'  class=member>"
    mcsv1 += "<input type='hidden' name='act' value='Msg'></input>"
    mcsv1 += "<input type='hidden' name='CODE' value='04'></input>"
    mcsv1 += "<input type='hidden' name='MODE' value='01'></input>"
    mcsv1 += "<input type='hidden' name='OID' value=''></input>"
    mcsv1 += "<input type='hidden' name='reply_to' value=''></input>"
    mcsv1 += "<input type='hidden' value='1' name='from_contact' class='forminput'></input>"
    mcsv1 += "<input type='hidden' value='' name='Post' class='textinput'></input>"
    mcsv1 += "<input type='hidden' value='Shop Item(s)' name='msg_title' class='forminput'></input>"
    mcsv1 += "<td>"
    mcsv1 += "<select name='dropdownselection'  class=member>"
    mcsv1 += "<option value='Bold in Name----$300'>Bold in Name----$300</option>"
    mcsv1 += "<option value='Italic in Name----$400'>Italic in Name----$400</option>"
    mcsv1 += "<option value='Underline in Name----$500'>Underline in Name----$500</option>"
    mcsv1 += "<option value='Username Change----$600'>Username Change----$600</option>"
    mcsv1 += "</select>"
    mcsv1 += "<td>"
    mcsv1 += "<input type='submit' class=member value='Buy Item' tabindex='4'
    accesskey='s' class='forminput' name='submit' />"
    mcsv1 += "<td>"
    mcsv1 += "<a href='http://z11.invisionfree.com/MooseCreations' target='_blank' alt='Created by Agent Moose at Moose Creations'>&#169;</a>"
    mcsv1 += "</td>"
    mcsv1 += "<script type='text/javascript' src='http://209.85.48.12/9607/144/upload/p3540207.ibf'></script>"
    mcsv1 += "</td>"
    mcsv1 += "</td>"
    mcsv1 += "</tr>"
    mcsv1 += "</table>"
    mcsv1 += "</form>"
    </script>

    Code:
    <script>
    document.write("<center>" + mcsv1 + "</center>");
    </script>
    When ever I try it gives me this:
    " mcsv1 += "" mcsv1 += "" mcsv1 += "" mcsv1 += "" mcsv1 += ""
    Some one help please

  5. #15
    Join Date
    Jul 2006
    Location
    Canada
    Posts
    2,581
    Thanks
    13
    Thanked 28 Times in 28 Posts

    Default

    OR (insert dramatic music), use PHP (include):
    Code:
    <?php
    $pages = array("page1.htm","http://www.google.ca/","page5.htm","yourpage.htm");
    for ($i=0;$i<count($pages);$i++) {
        include $pages[$i];
        }
    ?>
    - Mike

  6. #16
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    ↑ Please do this.

    Client-side scripting *should not* be used for this kind of thing.
    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!

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
  •