Results 1 to 2 of 2

Thread: website link on HTML

  1. #1
    Join Date
    Oct 2013
    Location
    Finland
    Posts
    52
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default website link on HTML

    What is the <> for that?

    EDIT: Found it but its only for <body> tag and i want to be in here:

    Code:
    function credit()
    {
    document.body.innerHTML="<pre><h3>These people helped me alot:<\/h3><br><br><a href="http://www.dynamicdrive.com/forums/"><\/pre>"
    }
    Last edited by NitroDev; 10-25-2013 at 06:07 PM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,375
    Thanks
    77
    Thanked 3,421 Times in 3,382 Posts
    Blog Entries
    12

    Default

    Code:
    function credit()
    {
    document.body.innerHTML+='<pre><h3>These people helped me alot:<\/h3><br><br><a href="http://www.dynamicdrive.com/forums/">Dynamic Drive<\/a><\/pre>'
    }
    Notice that I changed the outer delimiting quotes from double (") to single (') so that the quotes inside the string would not be seen as ending the string. I also changed innerHTML= to innerHTML+=. That should add it to the body's HTML rather than overwrite the body's HTML. But the problem with that is, if you've assigned events to elements in the body or another script has, and/or there's a form involved, things might not work as expected. Also, if the existing HTML is invalid, this very often will cause problems in at least some browsers.

    It's generally better to append an element to the body, then set its innerHTML to what you want it to be. In this case you could:

    Code:
    function credit()
    {
    var pre = document.createElement('pre');
    document.body.appendChild(pre);
    pre.innerHTML = '<h3>These people helped me alot:<\/h3><br><br><a href="http://www.dynamicdrive.com/forums/">Dynamic Drive<\/a>';
    }
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    NitroDev (10-26-2013)

Similar Threads

  1. HTML Website Updates
    By biomike in forum General Paid Work Requests
    Replies: 8
    Last Post: 05-19-2011, 09:51 AM
  2. my website in IE has 2 major html problems.
    By Johnnymushio in forum HTML
    Replies: 16
    Last Post: 12-07-2010, 05:04 AM
  3. Need help inserting script into my website html
    By tmendola in forum Looking for such a script or service
    Replies: 1
    Last Post: 08-06-2010, 07:14 AM
  4. xml on my html website
    By queerfm in forum HTML
    Replies: 2
    Last Post: 07-22-2006, 07:25 PM
  5. Create a html page from a website
    By 2ndglance in forum HTML
    Replies: 3
    Last Post: 09-14-2005, 08:22 PM

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
  •