I'm not a javascript expert but trying to make a new link inside a frame5 will make the link appear but it won't work.
Here's a very simple example,
the macro testJavaScriptLink :
Code: Select all
[h: sStr1 = macrolinkText("marioTest@this")]
[frame5("testFrame"):{
<!DOCTYPE html>
<html>
<head>
<script>
[r:"
function makeLink(elem){
var oStr = elem.getAttribute('data-test');
var oP = document.getElementById('idPar');
var oA = document.createElement('a');
oA.appendChild(document.createTextNode('New link!'));
oA.title='A Title';
oA.setAttribute('href',oStr);
oP.appendChild(oA); <!-- This doesn't work! -->
var oA2 = document.getElementById('pre-Link');
oA2.setAttribute('href',oStr); <!--we change the pre-existing link and it work-->
}
"]
</script>
<title> Something </title>
</head>
<body>
<p><a href='#' onclick='makeLink(this);' data-test='[r:sStr1]'>Make a link</a></p>
<p id='idPar'></p>
<p><a href=# id='pre-Link'>This link does not work</a></p>
</body>
</html>
}]
Code: Select all
[h:broadcast("Mario!")]
The function will make a new link with a macro String, and also will put the same string in the broken link. The previously broken link will now work, while the newly made link won't work even with the same href.
Am i doing something wrong here?
Edit: Just for the sake of it I've even tried to pass the whole HTML code as a string and to write it in the frame using innerHTML, the link still appears but it still doesn't work.