Hi folks
If I put
Code:
<script language='javascript' type='text/javascript'>
document.write("<a href=\'tellafriendtips.php?id="+location.href+"\' onclick=\"window.open(this.href,\'questions\',\'width=800,height=450,scrollbars,resizable,left=0,top=0\'); return false;\">Tell a friend</a>")
</script>
that works in my browser, as it should. However, I also want to syndicate this item, within a page, using a php javascript parser. This parser does not like double quotes in javascript, they all usually have to be singles- in which case javascript functions within the page syndicated by javascript continue to work. The parser does not cope with the double quotes round the onclick part (ie it refuses to syndicate any of the page) though it does handle the double quotes for the location.href part, if I split up the coding up to test it.
The parser can also cope happily with the following codes separately:
Code:
document.write("<a style=\'text-decoration:underline;\' href=\'http://ied.gospelcom.net/tellafriendtips.php?id="+location.href+"\'")
that writes the link perfectly in the syndicated version
Or, if I put, on its own,
Code:
document.write("onclick=\'window.open(this.href,\'questions\',\'width=800,height=450,scrollbars,resizable,left=0,top=0\'); return false;\'>Tell a friend</a>")
that writes the intended code exactly as intended, as above, minus the backslashes, in the syndicated version.
However, put them together, with single escaped quotes round the onclick part of the code, and although it displays the link in the syndicated version, the
second part is changed completely (at least as far as Firefox view source code is concerned), and it changes the second part of the code to (if Firefox can be trusted to show what happening - it does sometimes behave oddly with showing javascript source code):
Code:
onclick="window.open(this.href," questions="" ,="" width="800,height=450,scrollbars,resizable,left=0,top=0');" return="" false="">Tell a friend</a>
which of course does not work as a popup, though it continues to work as a link.
Changing what is escaped or not seems to makes no difference.
Any idea why the first lot of code seems to upsets the second onclick part when it is combined like this, and is there any way round it?
Blessings and thanks
Tony
Last edited by soon : 12-04-2006 at 11:06 AM.
Reason: Solved one problem, raised another
|