Hi
I wanted to pass some html for a div, from a chunk to a js variable.
shouldn’t i be able to do this.
<html>
<head>
<script>
function sayHello(){
alert(myVar);
}
myVar = {{test_chunk}};
</script>
</head>
<body onload="sayHello();">
</body>
</html>
test_chunk:
<div id=’text’>
<p>steve</p>
</div>
It works in FF on Mac and PC, but not safari on Mac or PC or IE on PC.
It appears in the source code of the page correctly, but i get a parse error and the onload does not run.
if i put "fff" in the test_chunk it will show in the alert box, so i think it is something to do with the quotes, but if i put quotes around some div html modx says xml error.
any thoughts ?
regards
steve
Modx chunks have nothing to do with IE. It your html/javascript that is not working correctly
hi
i am not sure what your on about. i never said chunks had anything to do with IE.
could explain what is wrong with my js/html then ?
hi
just avoid any confusion.
the html posted above is the index (or first ) page in modx and there is only one chunk being called.
it couldn’t be any simpler.
the contents of the chunk get written as you would expect into the source code of the page generated by modx. but for some reason ie and safari have a problem with putting the contents of the chunk into a js variable, as detailed above.
it all seems very straight forward
but only ff can do it.
i am sure there’s must be a simple solution
any ideas appreciated.
Why don’t you put your javascript in external files? This way there won’t be any html errors.
hi
thanks
that is the probably best.
i have been rebuilding a friends website, and i found this little glitch which i just could not solve.
regards