Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jul 2004
    Location
    mile high city
    Posts
    482
    Thanks
    0
    Thanked 0 Times in 0 Posts

    omitting elements associated with javascript

    I have a link pointing to a feature that requires a javascript enabled browser. But I'd like for this link not to appear for browsers without javascript enabled.

    So I use document.write('<a href=\"#\"></a>') to output the link to enabled browsers? Is this an appropriate use of document.write? Is there a better method?
    Computer, kill Flanders... Did I hear my name? My ears are burning...
    Good start. Now finish the job.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Nashua, NH
    Posts
    1,724
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    function feature(pID)
      { this.envokeElement = document.getElementById(pID).appendChild(document.createElement('span');
         this.envokeElement.appendChild(document.createTextNode('Click to Run Script'));
         this.envokeElement.onclick = function(e)
            { /* Do Stuff */
            };
      }
    
    <body onload="new feature('parentID')">
    Vladdy | KL
    "Working web site is not the one that looks the same on common graphical browsers running on desktop computers, but the one that adequately delivers information regardless of device accessing it"

  • #3
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    That seems a little... much? document.write()-ing out the link is an adequate solution.


  •  

    Posting Permissions

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