Code: Select all
if(!styleNode){
do stuff...
}else{
styleNode = document.removeChild(styleNode);
}
Any help is appreciated.
Moderator: General Moderators
Code: Select all
if(!styleNode){
do stuff...
}else{
styleNode = document.removeChild(styleNode);
}
Code: Select all
//!styleNode accesses variable value, which will cause an error if variable doesn't exist, but typeof doesn't
if(typeof styleNode == 'undefined'){
...
} else {
//removeChild must be called on elements parent which you want to remove
styleNode.parentNode.removeChild(styleNode);
}I'm having a hard time understanding exactly what that is supposed to mean. This is partly because whoever wrote the above would fail English, but also because I have no clue what a "namespace" is and how it impacts JavaScript or the use of this function.The function "createElement()" creates an element with the specified tag name defaulting namespace depending on the document.
Code: Select all
function myMakeElement()
{
var newElement = createElement('TD');
}Code: Select all
var node_div = ...;
var node_a = document.createElement('A');
node_a.setAttribute('href', 'http://www.google.com');
node_div.appendChild(node_a); //now it is in DomLemme guess... Internet Explorer?kaszu wrote:Note: node_a.getAttribute('href') for urls like /a.html may return http://domain.tld/a.html in some browsers
As alwaysLemme guess... Internet Explorer?
Code: Select all
function normalizeUrl(href) {
var domain = document.location.protocol + '//' + document.location.hostname;
return href.replace(domain, '');
}