Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Javascript PopOut Error
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 29 May 2013 :  05:41:03  Show Profile  Reply with Quote
There's a bit of code here which will enlarge an image (in a pop-out) when you move your mouse over it. However, if the image path or file name contains an apostrophe, the code breaks. Can anyone help fix this?

AnonJr
Moderator

United States
5768 Posts

Posted - 29 May 2013 :  13:26:11  Show Profile  Visit AnonJr's Homepage  Reply with Quote
You may have to run the image path/name through a function that url encodes the text before inserting it into the JavaScript (assuming the JavaScript is generated by some ASP... can't get to the site from work.)

You could change the JavaScript to use double quotes around the value, but you would run into the same problem if there was a double quote in the path/name. Better to take the time now and work on a more complete solution.
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 29 May 2013 :  16:15:18  Show Profile  Reply with Quote
Yes, the script is called via ASP. I've tried replacing it with an escape-apostrophe, with a pair of them, and with an ascii value; none had any effect.
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 30 May 2013 :  09:50:47  Show Profile  Visit AnonJr's Homepage  Reply with Quote
Are you doing a Server.URLEncode() on the image URL or are you just replacing ' with %27 ?
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 30 May 2013 :  13:56:04  Show Profile  Reply with Quote
I've tried both. Neither works with the apostrophe issue. Server.URLEncode kills the script for all files.
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 30 May 2013 :  18:01:50  Show Profile  Visit AnonJr's Homepage  Reply with Quote
Did you encode the whole bit of JavaScript or just the image url?
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 31 May 2013 :  02:04:34  Show Profile  Reply with Quote
I encoded the path and image URL before sending to Javascript.
Go to Top of Page

Doug G
Support Moderator

USA
6493 Posts

Posted - 31 May 2013 :  11:34:50  Show Profile  Reply with Quote
If you're setting an attribute with the image path perhaps you need to use server.htmlencode()

======
Doug G
======
Computer history and help at www.dougscode.com
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 31 May 2013 :  15:46:40  Show Profile  Visit AnonJr's Homepage  Reply with Quote
Server.HTMLEncode would be for displaying the URL on a page, it would render it useless as an actual link.
Go to Top of Page

Carefree
Advanced Member

Philippines
4207 Posts

Posted - 17 November 2015 :  21:58:15  Show Profile  Reply with Quote
Another reply to an ancient topic. I solved this issue by replacing any apostrophe with the Unicode "Prime" character (looks just like an apostrophe) and Javascript is fine with it.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000 Version 3.4.07