...

View Full Version : HARD ONE! window.open - Where's it go?



ghoulardi
03-19-2004, 04:27 AM
Im modifing an old version of ultrabar. Its an IE toolbar with customizable search engines. (better then google bar IMO)

Someone added a button to open non active urls by selecting (highlighting) them. It opens the url good but in the same window, I want to make them open in a new window.

Can someone Please help me :)
Give me some Ideas or mabey test it yourself if you have the time.
I know very little about javascript. Im using Resource hacker to edit the javascript in the Dll file. Its String 8, line 113.

Do I use window.open and how should it look?


javascript:q=(document.frames.length?'':document.selection.createRange().text);for(i=0;i<document.frames.length;i++){q=document.frames[i].document.selection.createRange().text;if(q!='')break;}if(q=='')void(alert('Nothing was selected. Please select an URL on the page. '));if(q!=''){if(q.substr(0,7)!=\"http://\"){parent.document.location.href=\"http://\"+q;}else{parent.document.location.href=q;}location.href=q}

Thanks a million if someone can help solve this, Ive been at it a week.

The toolbar .Rar
h**p://www33.brinkster.com/ricecrispies

glenngv
03-19-2004, 05:14 AM
Did you add the last statement location.href=q? If yes, then remove it.

Then change


if(q!=''){
if(q.substr(0,7)!=\"http://\"){
parent.document.location.href=\"http://\"+q;
}
else{
parent.document.location.href=q;
}
}

to


if(q!=''){
if(q.substr(0,7)!=\"http://\"){
window.open(\"http://\"+q, "_blank");
}
else{
window.open(q, "_blank");
}
}

I put the code in newlines for readability's sake.

ghoulardi
03-19-2004, 08:55 AM
Sorry I must have some how messed it up during copy/paste.
This is exactly how it looks

javascript:q=(document.frames.length?'':document.selection.createRange().text);for(i=0;i<document.frames.length;i++){q=document.frames[i].document.selection.createRange().text;if(q!='')break;}if(q=='')void(alert('Nothing was selected. Please select an URL on the page. '));if(q!=''){if(q.substr(0,7)!=\"http://\"){parent.document.location.href=\"http://\"+q;}else{parent.document.location.href=q;}}

This is what I tried from what you wrote

java script:q=(document.frames.length?'':document.selection.createRange().text);for(i=0;i<document.frames.length;i++){q=document.frames[i].document.selection.createRange().text;if(q!='')break;}if(q=='')void(alert('Nothing was selected. Please select an URL on the page. '));if(q!=''){if(q.substr(0,7)!=\"http://\"){window.open(\"http://\"+q, "_blank");}else{window.open(q, "_blank");}}

The problem is that
Resource hacker is giving errors and wont let me compile it.

example
"Compiler Error in line 6 at offset 351
Invalid statement: End of line expected"

I think it is refering to the qoutes around "_blank"
I have no idea why??? though.

I really apreciate your help Thank you !!!!!!!
If you dont want to mess with it anymore I dont blame you..

glenngv
03-19-2004, 09:07 AM
Use single quotes instead

'_blank'



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum