Results 1 to 8 of 8

Thread: Can I do this in javascript? Involves converting...

  1. #1
    Join Date
    Feb 2007
    Location
    Michigan
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Can I do this in javascript? Involves converting...

    I tried converting html to javascript using an online code converter, once the html converted to javascript, I saved the javascript output to a .js file. What I would like to do is have a single line in my html displaying the js content so that I can go in and change only this .js file when updating is needed. I expect the content to be displayed on multiple websites. If I update it from my server, I'd like it to change on all sites that the script would be on...

    So what I did was saved the javascript output I received, after converting the html to javascript, to a .js file and I tried making the content appear on my regular page by doing something like this <script language="javascript" src="http://www.mydomain.com/FILENAME.js"></script> but it is definitely not working...

    Is it possible to do something like this? If not, is there an alternative other than using an iFrame which I don't want to do...? The javascript code once it was converted from html is pasted below...

    Any help is greatly appreciated,

    Stiven USB


    -----------------------------------------------------------------------

    <script type="text/javascript" language="JavaScript">
    <!--
    document.writeln('<table width="380" border="1" bgcolor="#666666">');
    document.writeln(' <'+'!--DWLayoutTable-->');
    document.writeln(' <tr bgcolor="#000066"> ');
    document.writeln(' <td colspan="3" valign="top"><table width="100&#37;" border="0" cellpadding="0" cellspacing="0" bgcolor="#666666">');
    document.writeln(' <'+'!--DWLayoutTable-->');
    document.writeln(' <tr> ');
    document.writeln(' <td width="371" height="39" align="center" nowrap><a href="http://www.ultimatesportsbets.com"><img src="http://www.ultimatesportsbets.com/javabanner.gif" width="370" height="39" border="0"></a></td>');
    document.writeln(' </tr>');
    document.writeln(' </table></td>');
    document.writeln(' </tr>');
    document.writeln(' <tr> ');
    document.writeln(' <td width="87" height="20" bgcolor="#000066"><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong><u>Sport:</u></strong></font></td>');
    document.writeln(' <td colspan="2" valign="top" bgcolor="#000066"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">NBA ');
    document.writeln(' Basketball</font></strong></td>');
    document.writeln(' </tr>');
    document.writeln(' <tr> ');
    document.writeln(' <td bgcolor="#000066"><u><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>Match-up:</strong></font></u></td>');
    document.writeln(' <td width="272" valign="top" bgcolor="#000066"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Orlando ');
    document.writeln(' Magic (-7) @ Detroit Pistons</font></strong></td>');
    document.writeln(' </tr>');
    document.writeln(' <tr> ');
    document.writeln(' <td bgcolor="#000066"><u><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>Pick:</strong></font></u></td>');
    document.writeln(' <td valign="top" bgcolor="#000066"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Detroit ');
    document.writeln(' Pistons (+7)</font></strong></td>');
    document.writeln(' </tr>');
    document.writeln(' <tr> ');
    document.writeln(' <td bgcolor="#000066"><u><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><strong>Record:</strong></font></u></td>');
    document.writeln(' <td valign="top" bgcolor="#000066"><strong><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">11-3 ');
    document.writeln(' ATS</font></strong></td>');
    document.writeln(' </tr>');
    document.writeln('</table>');
    //-->
    </script>
    Last edited by StivenUSB; 03-02-2007 at 01:30 PM. Reason: Clarification

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

    Default

    Do not do this. The best way of achieving what you want is to use a server-side language. If you can't, use an <iframe>. <iframe>s are better-supported than Javascript, aren't commonly disabled, and also don't slow down the page load dramatically.
    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!

  3. #3
    Join Date
    Feb 2007
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey View Post
    Do not do this. The best way of achieving what you want is to use a server-side language. If you can't, use an <iframe>. <iframe>s are better-supported than Javascript, aren't commonly disabled, and also don't slow down the page load dramatically.
    On top of that, it's a lot easier to do it with php. If you have, say, a header that you want in ever page, just put the html for the header in a file called header.inc, and in each page, add the line

    <?php include("header.inc"); ?>

    That's all it takes. It's faster, and you don't need to call a function to write every line.

    I use that trick all the time.
    "Rock and roll ain't noise pollution." - AC/DC

    http://www.blake-foster.com

  4. #4
    Join Date
    Feb 2007
    Location
    Michigan
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So you are saying that all I would do is copy and paste my html and save it as header.inc? My apologies for being a bit oblivious to using php :-/...

    Then if I want that content to show up in my page, or if I want to tell someone how to place my content on their own page, I would tell them to download and upload the file header.inc to their server, then paste the snippet "<?php include("header.inc"); ?>" wherever they want the content to appear?

    If it is as simple as that then that's wonderful... My assumption however is that this snippet "<?php include("header.inc"); ?>" would be placed in the <head> section of my html and I would need further code in the <body> to make the content appear... no?

    At any rate, please let me know as I really appreciate your help Blake... If anyone else has any input it is much appreciated.

    Thank you,

    StivenUSB

  5. #5
    Join Date
    Feb 2007
    Posts
    116
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    No that's not quite it.

    Any content you want to appear in multiple pages can go in a .inc file. You could call it whatever you want as long as it ends in .inc. Then, you put the include thing in the place where you want to the content to appear. Here's an example:

    header.inc:

    Code:
    <html>
    <head>
    <title>Welcome to my web page!</title>
    </head>
    <body>
    footer.inc

    Code:
    </body>
    </html>
    page1.php

    Code:
    <?php include("header.inc") ?>
    This is page 1.
    <?php include("footer.inc") ?>
    page2.php

    Code:
    <?php include("header.inc") ?>
    This is page 2.
    <?php include("footer.inc") ?>
    Now, if you open page1.php, the server will send the following to your browser:

    Code:
    <html>
    <head>
    <title>Welcome to my web page!</title>
    </head>
    <body>
    This is page 1.
    </body>
    </html>
    And if you open page2.php, the server will send the following to your browser:

    Code:
    <html>
    <head>
    <title>Welcome to my web page!</title>
    </head>
    <body>
    This is page 2.
    </body>
    </html>
    Any change you make to header.inc or footer.inc will now show up in both files.
    "Rock and roll ain't noise pollution." - AC/DC

    http://www.blake-foster.com

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

    Default

    It doesn't even have to end in .inc, that's just a convention.
    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!

  7. #7
    Join Date
    Feb 2007
    Location
    Michigan
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Well I guess I will just do it in html on its own page and then include it for myself or for any other person who would want the content in a nonscrollable iFrame...

    One thing with these iframes though.. Are they search engine friendly? Is it beneficial to include the <noscript> tag or is that only for older browsers and for people that access your page from a pda for example..? My page is a sports related website and when it is redesigned, I will be getting a lot of my content via iframes, perhaps 2-3 per page at times. I am just wondering how this will effect my PR..

    I have received great support from this forum thus far and thank you to everyone for your help.

    StivenUSB

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

    Default

    One thing with these iframes though.. Are they search engine friendly?
    Not really, no. They're better than Javascript, though.
    Is it beneficial to include the <noscript> tag or is that only for older browsers and for people that access your page from a pda for example..?
    Usually, yes, but I don't know what you'll be able to do with it in this case.
    My page is a sports related website and when it is redesigned, I will be getting a lot of my content via iframes, perhaps 2-3 per page at times. I am just wondering how this will effect my PR..
    Badly. The only method that won't is server-side scripting. If you're thinking of hosting a big website (big enough to care about page rank), you should definitely invest money in hosting with server-side scripting support and time in learning to use it properly.
    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
  •