Reply
Making a jasvascript get scraped correctly
Old 12-02-2006, 07:10 PM Making a jasvascript get scraped correctly
Skilled Talker

Posts: 65
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
soon is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Reply     « Reply to Making a jasvascript get scraped correctly
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.10598 seconds with 12 queries