Javascript PopOut Error - نوشته شده در (2554 Views)
Advanced Member
Carefree
مطلب: 4224
4224
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?
 پیش‌فرض مرتب‌سازی برای تاریخ DESC به معنی جدیدترین است  
 تعداد در صفحه 
نوشته شده در
Forum Moderator
AnonJr
مطلب: 5768
5768
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.
نوشته شده در
Advanced Member
Carefree
مطلب: 4224
4224
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.
نوشته شده در
Forum Moderator
AnonJr
مطلب: 5768
5768
Are you doing a Server.URLEncode() on the image URL or are you just replacing ' with %27 ?
نوشته شده در
Advanced Member
Carefree
مطلب: 4224
4224
I've tried both. Neither works with the apostrophe issue. Server.URLEncode kills the script for all files.
نوشته شده در
Forum Moderator
AnonJr
مطلب: 5768
5768
Did you encode the whole bit of JavaScript or just the image url?
نوشته شده در
Advanced Member
Carefree
مطلب: 4224
4224
I encoded the path and image URL before sending to Javascript.
نوشته شده در
Support Moderator
Doug G
مطلب: 6493
6493
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
نوشته شده در
Forum Moderator
AnonJr
مطلب: 5768
5768
Server.HTMLEncode would be for displaying the URL on a page, it would render it useless as an actual link.
نوشته شده در
Advanced Member
Carefree
مطلب: 4224
4224
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.
 
شما باید یک متن وارد کنید