SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SEO Link Building Master I, Brian's Avatar
    Join Date
    Apr 2003
    Posts
    1,284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Remedial question

    Hi there -

    I have a piece of HTML code I want to insert into the main template of a site using Javascript, but I'm not quite sure what I need to do.

    I figure I'll need to call up the script using something like:

    Code:
     <SCRIPT LANGUAGE="JavaScript1.4" SRC="/js/html.js" TYPE='text/javascript'></SCRIPT>
    I tried putting the HTML code within:

    Code:
     document.write(' HTMLcode ');
    and saving it as a .js document, but that didn;t work.

    As you can probably etll, I'm not at all used to JS, and am simply fumbling around here.

    Any pointers on how to solve this little chestnut would be most appreciated.
    Internet Business Forums - free business help & advice

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    one solution


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">

    <html>

    <head>
    <title></title>
    </head>
    <script language="JavaScript" type="text/javascript">
    <!--

    function AddHeader(){
    header=document.createElement('DIV');
    document.getElementsByTagName('BODY')[0].appendChild(header);
    header.style.position='absolute';
    header.style.top='0px';
    header.style.textAlign='center';
    header.style.width='500px'; // use the width of your page
    headerHTML='';
    headerHTML+='My Header HTML<br>';
    headerHTML+='Another Line<br>';
    header.innerHTML=headerHTML;
    }

    //-->
    </script>
    <body onload="AddHeader();" >

    </body>

    <br>
    <br>
    <br>
    <br>
    <br>
    <br>
    Put the function AddHeader() in an external JavaScript
    </html>

    Last edited by vwphillips; Jan 2, 2005 at 17:07.

  3. #3
    SEO Link Building Master I, Brian's Avatar
    Join Date
    Apr 2003
    Posts
    1,284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply, vwphillips - somehow it looks a little overcomplicated from here??
    Internet Business Forums - free business help & advice

  4. #4
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by I, Brian
    Thanks for the reply, vwphillips - somehow it looks a little overcomplicated from here??
    what do you find complicated?

    I can help in finding the window width
    You only need to add the HTML code for your headed in variable 'headerHTML'
    and space the balance of you page down from the header height(is that your problem?)


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
  •