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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question HTML in JavaScript

    I have a menu created in JS and i want one of the links to open in a new Browser window.
    How can i do this? Is it possible to insert an HTML tag (<a href...>) in JS ?

  • #2
    New Coder
    Join Date
    Oct 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Have you tried adding target="_blank" to your <a href> link tags?

    This should cause the link to be loaded in a new browser window.

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It's easier to help you if you can show us some code...

    But usually you can insert the <a> tag using innerHTML, as:
    Code:
    containerElement.innerHTML = '<a href="...">Link</a>';
    Or use the DOM:
    Code:
    var aTag = document.createElement("A");
    var text = document.createTextNode("Link");
    aTag.appendChild(text);
    containerElement.appendChild(aTag);
    /Daniel

  • #4
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The menu i'm using is the HV Menu available in Dynamic Drive.


  •  

    Posting Permissions

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