...

View Full Version : HTML in JavaScript



Luis Ribeiro
10-17-2003, 05:55 PM
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 ?

skidvd
10-17-2003, 07:01 PM
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.

Danne
10-17-2003, 07:09 PM
It's easier to help you if you can show us some code...

But usually you can insert the <a> tag using innerHTML, as:


containerElement.innerHTML = '<a href="...">Link</a>';


Or use the DOM:


var aTag = document.createElement("A");
var text = document.createTextNode("Link");
aTag.appendChild(text);
containerElement.appendChild(aTag);

Luis Ribeiro
10-20-2003, 10:47 AM
The menu i'm using is the HV Menu available in Dynamic Drive.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum