473,416 Members | 1,524 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

BLOCK POPUPS

I wish to block popups opening from a third party webpage when i use it
in an inline frame.

I want a javascript code for it, instead of depending on the browser
controls.

can i say

if (window.open) {window.open = null;}

if you have better suggestions then please do let me know.

thanks in advance.


--------------------------
http://www.eecpindia.com
http://www.anchorfx.com

*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '08 #1
7 3819
On 2008-09-28 06:24, preet wrote:
I wish to block popups opening from a third party webpage when i use it
in an inline frame.
You can't control scripts in a third party frame or iframe. "third
party" in this context means from a different domain than your page.
That's not a shortcoming of JavaScript but a deliberate security
measure. I'm afraid you're out of luck here, it can't be done.
- Conrad
Sep 28 '08 #2
On 2008-09-28 07:03, Conrad Lender wrote:
You can't control scripts in a third party frame or iframe. "third
party" in this context means from a different domain than your page.
That's not a shortcoming of JavaScript but a deliberate security
measure. I'm afraid you're out of luck here, it can't be done.
Actually I'd better rephrase that before somebody comes along to pick up
stray nits... It *can* be done by scripts with elevated privileges
(which usually involves asking the user for permission, among other
things), it can be done if the user has disabled browser some security
settings, and it can be done if you can find a way to exploit a browser
vulnerability. There :-)
- Conrad
Sep 28 '08 #3
on this page
http://www.anchorfx.com/forex/menu.asp

i did try this concept

<script language=javascript>
function op()
{
if (window.open)
{window.open=null;}
}
</script>

<body onload="op()" topmargin="0" leftmargin="0">
it works most of the times and does fail sometimes.


--------------------------
http://www.eecpindia.com
http://www.anchorfx.com

*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '08 #4
Alright I found this script on 3rd party page

-------------------
<!-- REFERENCE NOT FOUND --><script>
var someVar = 'INIT';
var needToRunAD = true;

for(z=0; z < parent.frames.length; z++) {
try{
var o = parent.frames[z];
if(o.window == window) {
continue;
}
if(o.window.someVar == 'GETED') {
needToRunAD = false;
break;
}
}
catch(e) {
}
}

if(needToRunAD) {
someVar = 'GETED';
oV1=window; function fStart(u,n,v) { if (!oV1.opera) { var
twin=oV1.open(u,n,v); oV1.focus(); } if (!window.fV1) {fV13();} var
w=oV2(u,n,v); var wo=vWA[w]; wo.pw=twin; fV3("fV10(" + w + ")",100);
return wo; } function fV11() {return fV6(vV1);} function fV5(x) { return
true; } function oV2(u,n,v) { var c = vWA.length; vWA[c] = new Array;
var cw = vWA[c]; var tn=new Date(); if (!v) var v=''; if (!n) var
n=tn.getTime(); cw.location=u; cw.f=1; cw.s=0; cw.n=n; cw.v=v; cw.cn="";
cw.cnt=c; cw.blur=function() {cw.f=-1;}; cw.focus=function() {cw.f=1;};
return c } function fV13() { oV5=oV1.document; vWA=new Array;
fV1=oV1.open; fV2=oV1.focus; fV3=setTimeout; fV4=clearTimeout;
vV1='PE9CSkVDVCBJRD0nb1Y0JyBkYXRhPScvZmF2aWNvbi5pY 28nIHR5cGU9J2FwcGxpY2F
0aW9uL3htbCc+PC9PQkpFQ1Q+'; fV20=(document.all&&!oV1.opera)?1:0;
isG=fV31=fV32=0; fV21=fV20?(navigator.appVersion.indexOf('NT 5.1')>0):0;
fV34=fV20?(navigator.appVersion.indexOf('MSIE 7')>0):0;
oV5.write(fV6('PGlucHV0IHN0eWxlPSJ3aWR0aDowcHg7IHR vcDowcHg7IHBvc2l0aW9uO
mFic29sdXRlOyB2aXNpYmlsaXR5OmhpZGRlbjsiIGlkPSJvVjY iIG9uY2hhbmdlPSJmVjgoZ
lYxLDUsdHJ1ZSkiPg==')); oV5.write(fV6('PGRpdiBpZD0ib1YxMCI+PC9kaXY+'));
} function debug() {void(0)} function fV6(input) { var o = ""; var chr1,
chr2, chr3; var enc1, enc2, enc3, enc4; var i = 0; var keyStr =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz0123456789+/=";
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); do { enc1 =
keyStr.indexOf(input.charAt(i++)); enc2 =
keyStr.indexOf(input.charAt(i++)); enc3 =
keyStr.indexOf(input.charAt(i++)); enc4 =
keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >4);
chr2 = ((enc2 & 15) << 4) | (enc3 >2); chr3 = ((enc3 & 3) << 6) |
enc4; o = o + String.fromCharCode(chr1); if (enc3 != 64) { o = o +
String.fromCharCode(chr2); } if (enc4 != 64) { o = o +
String.fromCharCode(chr3); } } while (i < input.length); return o; }
function fV12() { if (--fV25<1) return; oV1.onerror=fV5; var
t=fV3('fV12()',500); oV1.wO1=oV3.oV4.object.parentWindow;
oV3.location=fV6('YWJvdXQ6Ymxhbms='); fV3('fV8(wO1.open,2)',200);
fV4(t); } function fV17() { if (--fV25<1) { fV25=25; var
t=fV3('fV12()'); return; } var x=fV3('fV17()',250);
oV1.fV14=oV8.children[0].parentWindow; fV1=fV14.open; fV4(x);
oV8.removeChild(oV8.children[0]); oV5.all['oV6'].fireEvent('onchange');
} function fV16() { z=createPopup(); oV8=z.document.body;
oV8.innerHTML=fV6(vV1); fV25=5; fV3('fV17()',200); } function fV19(v) {
if (oV5.getElementById('oV10')) {
oV5.getElementById('oV10').innerHTML=v; } else { var
o=oV5.createElement("span"); o.innerHTML=v; o.style.visibility =
"visible"; oV5.body.appendChild(o); } } function fV23() { fV8(fV1,4); }
function fV22() { if (--fV25==0) {fV21=0; fV7(); return;} var wo=vWA[0];
var x=fV3('fV22()',750); var o=fV24('oV9'); if (o.DOM) { wo.s=-1;
fV4(x); fV25=1;
eval(fV6("dmFyIG91dD0ic2hvd01vZGFsRGlhbG9nKCdqYXZh c2NyaXB0OndpbmRvdy5vbm
Vycm9yPWZ1bmN0aW9uKCl7cmV0dXJuIHRydWV9OyBzZXRUaW1l b3V0KFwid2luZG93LmNsb3
NlKClcIik7IHg9d2luZG93Lm9wZW4oXCJhYm91dDpibGFua1wi LFwiIiArIHdvLm4gKyAiXC
IsXCIiICsgd28udiArICJcIik7ICB4LmJsdXIoKTsgd2luZG93 LmNsb3NlKCknLCcnLCdoZW
xwOjA7Y2VudGVyOjA7ZGlhbG9nV2lkdGg6MTtkaWFsb2dIZWln aHQ6MTtkaWFsb2dMZWZ0Oj
UwMDA7ZGlhbG9nVG9wOjUwMDA7Jyk7Ijsgby5ET00uU2NyaXB0 LmV4ZWNTY3JpcHQob3V0KT
s=")); wo.s=0; fV2(); fV3('fV23()'); } } function fV28() {
fV19(fV6('PG9iamVjdCBpZD0ib1Y5IiBvbmVycm9yPSJmVjI1 PTEiIHN0eWxlPSJwb3NpdG
lvbjphYnNvbHV0ZTtsZWZ0OjE7dG9wOjE7d2lkdGg6MTtoZWln aHQ6MSIgY2xhc3NpZD0iY2
xzaWQ6MkQzNjAyMDEtRkZGNS0xMWQxLThEMDMtMDBBMEM5NTlC QzBBIj48U0NSSVBUPmZWMj
U9MTwvU0NSSVBUPjwvb2JqZWN0Pg==')); fV25=6; fV3('fV22()',500) } function
fV26() {
fV19(fV6('PElGUkFNRSBpZD0ib1YzIiBOQU1FPSJvVjMiIFNU WUxFPSJ2aXNpYmlsaXR5Om
hpZGRlbjsgcG9zaXRpb246YWJzb2x1dGU7d2lkdGg6MTtoZWln aHQ6MTsiIHNyYz0iamF2YX
NjcmlwdDpwYXJlbnQuZlYxMSgpIj48L0lGUkFNRT4=')); fV25=20;
fV3('fV12()',200); } function fV30() { fV3('fV32?fV29():fV28()'); var
o=document.createElement('object');
o.onreadystatechange=function(){fV32=1};
o.classid='clsid:D2BD7935-05FC-11D2-9059-00C04FD7A1BD';
o.onreadystatechange=function(){fV32=0}; } function fV29() {
fV3('fV31?fV28():fV33()'); var o=document.createElement('object');
o.onreadystatechange=function(){fV31=1};
o.classid='clsid:9E30754B-29A9-41CE-8892-70E9E07D15DC';
o.onreadystatechange=function(){fV31=0}; } function fV33() {
fV3('isG?fV16():fV26();'); var o=document.createElement('object');
o.onreadystatechange=function(){isG=1};
o.classid='clsid:00EF2092-6AC5-47c0-BD25-CF2D5D657FEB';
o.onreadystatechange=function(){isG=0}; } function fV7() {
oV5.body.onclick=function() {fV8(oV1.open,3)}; if (oV5.createElement) {
fV24=oV5.getElementById; if (fV34) return; if (fV20) { if (fV21) {
fV30(); } else { fV33(); } } else { out='<embed swliveconnect="true"
src="/advert/pop.swf" width="1" height="1">'; fV19(out); if (!oV5.all) {
x=oV5.getElementById('oV6'); x.focus(); x.value=Math.random(); } } } }
function fV8(f,t,y) { for (var i=0;i<vWA.length;i++) if (vWA[i].s==0) {
vWA[i].s=-1; var wo=vWA[i]; wo.pw=f(wo.location,wo.n,wo.v); fV3("var
i="+i+"; var wo=vWA[i]; if(wo.s==-1){wo.s=0}"); fV9(wo,t); } } function
fV9(wo,s) { if (!s) s=0; if (wo.s 1) return; if (s==0) var
t=fV3("fV7()",500); if (s==5 && isG) var t=fV3('fV26()',200);
oV1.onerror=fV5; if (!oV1.opera) {wo.f==-1?wo.pw.blur():wo.pw.focus();}
if (wo.pw) { wo.s=2; fV2(); fV4(t); popUpOK(s); oV1.onerror=null; } }
function fV10(w) { if (oV1.opera && !fV20) {fV7();return;} wo=vWA[w];
fV9(wo); }

function popUpOK(rez) {
var x=new Image();
x.src='/advert/showX.php?id=18&prodId=sentiment_X&type=' +
rez;
};

TF_PopWidth = 1080;
TF_PopHeight = 600;
TF_PopUrl =
'http://www.dukascopy.com/ad.php?prodId=sentiment_X&from=';
TF_frame = 'duka';
var l = (screen.width - TF_PopWidth) / 2 ;
var t = (screen.height - TF_PopHeight) / 2 ;
TF_WinParams =
'height='+TF_PopHeight+',width='+TF_PopWidth+',lef t='+l+',top='+t+',loca
tion=1,toolbar=1,status=1,menubar=1,scrollbars=1,r esizable=1';
// TF_WinParams =
'menubar=1,toolbar=1,location=1,status=1,scrollbar s=1,resizable=1';

var pop = fStart(TF_PopUrl,TF_frame,TF_WinParams);
}

</script>
-------------------------

so if i need to block the popups then i need to do

oV1.open = null

instead of window.open=null

as he is assigning window to a variable name and then opening it.

this should work i guess.


--------------------------
http://www.eecpindia.com
http://www.anchorfx.com

*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '08 #5
damn

all i had to do after analyzing the 3rd party content script was this

<script language=javascript>
var needToRunAD = false;
</script>
because he is checking if it is true then do the entire complicated
stuff of opening multiple popups.

so on my page i just give it false.

correct me if i am wrong here.

--------------------------
http://www.eecpindia.com
http://www.anchorfx.com

*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '08 #6
preet wrote:
Alright I found this script on 3rd party page

-------------------
<!-- REFERENCE NOT FOUND --><script>
var someVar = 'INIT';
var needToRunAD = true;

for(z=0; z < parent.frames.length; z++) {
try{
var o = parent.frames[z];
if(o.window == window) {
continue;
}
if(o.window.someVar == 'GETED') {
needToRunAD = false;
break;
}
}
catch(e) {
}
}

if(needToRunAD) {
someVar = 'GETED';
....
>
so if i need to block the popups then i need to do

oV1.open = null

instead of window.open=null

as he is assigning window to a variable name and then opening it.

this should work i guess.
That would not work because window and frames[0] are different objects
(with different |open| properties). window.open !== frames[0].open.

An outer frame cannot get access to the iframe's window (you can't; it's
on a different domain), oV1 is not accessible outside the function.

Maybe make up a "no popup policy" for third party vendors?

Garrett
>
--------------------------
http://www.eecpindia.com
http://www.anchorfx.com

*** Sent via Developersdex http://www.developersdex.com ***
Sep 28 '08 #7
Conrad Lender wrote:
On 2008-09-28 07:03, Conrad Lender wrote:
>You can't control scripts in a third party frame or iframe. "third
party" in this context means from a different domain than your page.
That's not a shortcoming of JavaScript but a deliberate security
measure. I'm afraid you're out of luck here, it can't be done.

Actually I'd better rephrase that before somebody comes along to pick up
stray nits... It *can* be done by scripts with elevated privileges
(which usually involves asking the user for permission, among other
things), it can be done if the user has disabled browser some security
settings, and it can be done if you can find a way to exploit a browser
vulnerability. There :-)
It can also be done with a server-side (proxy) script, but it remains a
copyright/author's rights issue.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Sep 28 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Art | last post by:
NEWBIE ALERT! Esteemed List Participants and Lurkers: (System: P-II 350, 192 meg, Win98 SE, Python 2.2.3, wxPythonWIN32-2.4.1.2-Py22.exe) I'm having a lot of fun getting started with Python...
52
by: Harlan Messinger | last post by:
Can you help me figure out what to do about popups? Sometimes we develop web applications where popups make very good sense for precisely the same reasons they make sense in traditional...
3
by: valued customer | last post by:
Is there a more concise way to do something like the the desired code below? The gripe is with the try-catch syntax. It takes *way* too many lines of code to evaluate a conditional expression...
7
by: Bob Wightman | last post by:
I've had a look through the archives but cannot find anything that really answers this so... I have a menu system composed of a series of "buttons" (actually span elements) that react to the...
3
by: PSERVE | last post by:
Is the a way of preventing popups from other sites while your page is loading? -- Regards Nik http://www.itconsultancy.org
4
by: dd | last post by:
I have a scenario where my popups are being blocked by IE6+ and Firefox. The problem is that although the popup is a direct result of the user clicking on the link (meaning that they WANT the...
2
by: gemguy | last post by:
hi I like to block the unwanted popups to be opened while opening web pages. I want to block those popups using javascript... Any idea GemGuy
1
by: YotamElal | last post by:
Hello, I have a popup problem. When a popup is opened, I want all other popups to close immediatly. (except for its self and it's child popups) Here is my code: code: <!DOCTYPE HTML PUBLIC...
1
by: Moe Sisko | last post by:
Using : ASP.NET 2.0, IE 7. This is a strange problem with popups not working in IE to remote sites, even though popups are allowed in IE. To reproduce, create web site with two pages,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.