Javascript issue - OEP gets some but not others

Author Message
Ian 08/28/2005 09:09 am
I know Javascript (JS) calculations are a difficult task, but I`m getting an odd issue. OEP will detect and follow some JS links just fine, but not others when the functions are nearly identical (see bottom).

I was wondering if there is a way for me as an end user to see if the problem is the with the JS function call or some other parsing/scanning issue with the page. It saves the page, but I see no evidence in the queue that it parsed it. Also, some other pages have similar function calls and all links are explored.

I`ve restarted this project a couple times while trying to fine tune the substitutions, and was wondering if restarting (download all files) will ever use old saved files/settings. Or will it always use the most current files/settings.

In a related question, if I do a URL substitution one way on one run. Then I change the substitution rule and do an UPDATE modified files, how does OEP handle that.


CODE BELOW:

JS that works with the following link:

<PRE>
<CODE>
href="javascript:detect2(`7`)"

function detect2(image_number){
if ((navigator.userAgent.indexOf("Mac")!=-1) && (navigator.userAgent.indexOf("MSIE")!=-1)) {
processForm2(image_number);
}
else{
openWindow2(image_number);
}
}
function processForm2(image_number) {
url = "../picture_viewer/index.php@id=9&image_count=20&section=exclusive&referer=&image_number=" + image_number
window.open(url, "picture_viewer", "scrollbars=no,width=753,height=510");
return false;
}
function openWindow2(image_number) {
x = (753 - 753)/2, y = (510 - 510)/2;
if (screen) {
y = (screen.availHeight - 400)/2;
x = (screen.availWidth - 600)/2;
}
if (screen.availWidth > 1800) {
x = ((screen.availWidth/2) - 510)/2;
}
url = "../picture_viewer/index.php@id=9&image_count=20&section=exclusive&referer=&image_number=" + image_number
window.open(url,`picture_viewer`,`width=753,height=510,screenX=`+x+`,screenY=`+y+`,top=`+y+`,left=`+x);
}
</CODE>

This JS fails with the following link
<CODE>
href="javascript:detect_img2(`1`)"
function detect_img2(image_number){
if ((navigator.userAgent.indexOf("Mac")!=-1) && (navigator.userAgent.indexOf("MSIE")!=-1)){
processForm_img2(image_number);
}
else{
openWindow_img2(image_number);
}
}

function processForm_img2(image_number){
url = "../picture_viewer/index.php@id=432&image_count=10&section=pictorials&image_number=" + image_number;

window.open(url, "picture_viewer", "scrollbars=no,width=753,height=510");
return false;
}

function openWindow_img2(image_number){
x = (753 - 753)/2, y = (510 - 510)/2;

if (screen) {
y = (screen.availHeight - 400)/2;
x = (screen.availWidth - 600)/2;
}
if (screen.availWidth > 1800) {
x = ((screen.availWidth/2) - 510)/2;
}
url = "../picture_viewer/index.php@id=432&image_count=10&section=pictorials&image_number=" + image_number;
window.open(url,`picture_viewer`,`width=753,height=510,screenX=`+x+`,screenY=`+y+`,top=`+y+`,left=`+x);
}

</CODE>
</PRE>

I`m not sure which path OEP takes and if that would make a difference. The only real difference I can see in the above is that the second (non-working) has a ";" at the end of the URL string. I don`t have enough knowledge of JS to know if that`s correct syntax. But it is the only difference.

Finally, I was wondering about the feasibility of the following
Feature Request: Make OEP replace/translate a Javascript function call with any link that is called. Am I wrong in thinking that if a link gets enqueued from a script calculation, then that link can replace the function call in the offline copy.

Thanks. This is definitely the best offline browser I`ve tried thus far.
Oleg Chernavin 08/31/2005 12:24 pm
Thank you for your kind words! Can I ask you to send me a URL of the page with that script? I will see what is wrong exactly and try to improve Offline Explorer. If it is personal or requires a logon, please contact me using support@metaproducts.com.

Regarding URL Substitutes - I am afraid, there could be an unexpected behavior when some files are not changed since the last download - Offline Explorer will get links from them to follow and these links may appear to be invalid, because they were changed by the substitution rules.

Best regards,
Oleg Chernavin
MP Staff