PDA

View Full Version : Context Menu Iframe won't work!



Gabber
07-07-2005, 05:45 PM
http://www.dynamicdrive.com/dynamicindex1/contextmenu.htm

With this nice script, when I put a iframe has target, it won't work.



<SCRIPT language=JavaScript>
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//-->
</SCRIPT>

This piece of code causes the problem, but it's necessary for another script...
How can I do this now?

Greetz :)

Twey
07-07-2005, 06:07 PM
Which script requires this? It looks to me to just be standard error- and window-muffling code.
Comment it out and try everything.

jscheuer1
07-07-2005, 08:08 PM
With this nice script, when I put a iframe has target, it won't workThe window.open() method targets a new or existing window. If you want to target a frame or iframe, do it by its name, id or any method of identifying it via javascript script, using the location.href=, location.href.replace() or src= methods. Or use a regular link with the target attribute set to the frame/iframe's name.

Gabber
07-07-2005, 09:40 PM
Jscheuer1 - Well, I tried all those methods... none works in the script I mentioned above (see link).

Twey - the script is one that says the time on page... so it needs load and unload elements... IF I take the whole thing, it won't work. :\

jscheuer1
07-07-2005, 10:05 PM
They will all work in any script, if written correctly and used for what they will do. Let's see your full code or:

.

Gabber
07-08-2005, 01:33 AM
The page has a lot of scripts... all work (except sound in FF).

1- I took a line of the script I posted... and it worked fine offline.

2- I upload, and see the page online. Does not work. Why? My host adds 2 scripts, one after the body (!) and other in the middle of the html... it's exactly the same as I pasted above.... so even if I have that script without the line that causes the problem... it has another duplicate with that line...

hence... stuff does not work!
Is there a way my host won't add anything?

url:

http://gabber.no.sapo.pt/indexframe.htm


Thanks for the help

jscheuer1
07-08-2005, 05:46 AM
I'm still not clear on what it is that you want to have happen and when. Also, are you now saying that the iframe gets targeted after all, just not live due to conflicts with your host's scripts?

Gabber
07-08-2005, 12:58 PM
see the source of that link.
I changed this:


<SCRIPT language=JavaScript>
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//-->
</SCRIPT>

into


<SCRIPT language=JavaScript>
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}


//-->
</SCRIPT>


and stuff worked again in my pc... :) So I basically did a small fix...
but I dunno how, the place here I have my files hosted adds 2 script, including this one again!


<SCRIPT language=JavaScript>
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//-->
</SCRIPT>

now how do I work this out?
:(

jscheuer1
07-08-2005, 01:58 PM
Give your script all different names for the variables and functions so that it will not conflict with the host's script. Then when you make calls to it, use the new name. Then the host's script can sit idly by while yours operates.

Twey
07-08-2005, 03:58 PM
All you did to that page was disable the no-window-opening code. You now have a function (SymWinOpen()) which isn't ever going to be called.

Gabber
07-08-2005, 05:31 PM
Sure, but whatever I did, things worked offline and they didn't workwithout deleting that line! Since my host adds the exact same code (with the line), what can I do?
Is there a way to stop the host from adding that stuff? OR is there a way to override it?
I can't give different names for the variables: the problem seems to be in window.open! and I can't replace that (at least the alternatives you gave me wont' work).
So how shall I resolve this?

Twey
07-08-2005, 05:45 PM
You'll notice that there is:

var SymRealWindowOpen = window.open;
Put
<script type="text/javascript">
window.open = SymRealWindowOpen;
</script> somewhere so that it will be after your host's code.


N.B.: I'm not sure if this would be allowed under your host's contract; read it thoroughly first.
Also, I don't actually think this is your host's code. It's exactly the same as the code Norton Internet Security inserts into pages to stop popups, as part of its "ad blocking" option. If this is so, you needn't worry about the host not liking your overriding its code, but you will have to check for it first:

if(SymRealWindowOpen) window.open = SymRealWindowOpen;

Gabber
07-09-2005, 01:17 AM
Well! You said the magic word... Norton!
duh... NIS is getting to more more a pain in the ass than a good program.

In fact, I always doubted my host would put extra code, they never did before. I tough it might be some anti-spam new measure...
When you said norton it reminded me yes, it might add some stuff like that!
I disabled ad-block (using SP2 or FF one won't need it much), and done...
But... if I maintain this code:



<SCRIPT language=JavaScript>
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//-->
</SCRIPT>


it won't work...
I must take this line off: window.open = SymWinOpen;

Then all works fine! (perhaps it's because there are too many JS in the page).
This NIS is stupid, since it can be overriden with just some lines of code... so, a dull protection, which actually does harm when you visit sites (now I know why some had trouble opening windows).
As if JS interactions, HTML error and all sort of little "big" details were not enough! lol


Thanks for all the help! :)
The "mystery" is solved...