Link to home
Start Free TrialLog in
Avatar of lenz8as
lenz8as

asked on

browser detection

i am using ASP to develop web application..

so, if i wana detect the browser, i know i can do it by using HTTP_USER_AGENT, or even navigator.appName in javascript or Browser component..

but, if i wana detect if the user's browser will blocked all pop up window???

like if in my code hav window.open(..) in page onload..

i cant execute this code if user's browser block popup window..

how do i detect browser with blocked pop up window???

thanx for help..
Avatar of cristy56
cristy56

I don't think you can detect that.
Just think if u can detect some customized settings in the client side and modify it, it will be very insecure.

Cristy
Avatar of lenz8as

ASKER

t if i use pop up blocker, when in onload, i try execute window.open(...), it cant be done.. cant open new window..

but when i use a link, like when user click a button, then just execute window.open(...), script will be executed...

y??? who know how pop up blocker detect  user action wheter a user click a button to open new window or the application open new window without user interaction...
Since the popup are done clientside you have to detect wether popup-block are active clientside.

This can then be checked with ie JavaScript:

Ex1:

<script language="JavaScript" type="text/javascript">

var popupWindow=false;

popupWindow = window.open("http://somurl.com");

if(popupWindow){
  // The popup has not ben blocked do what ever
}else{
  // The popup has been blocked , do whatever.
}

</script>

If you need this information serverside you could ie create a form and set a value like bloc=true or false and post it to the actual page you wanna show.
Ok... can always give an example of "need it serverside"
This can of course be modified to be better, but the basic are.

<html>

<head>
  <title>PopUp Check Window - Redirect</title>
</head>

<body>

<form id="blockdetect" action="page2.asp" method="POST">
  <input type="hidden" id="pblock" name="pblock" value="not_blocked">
</form>

</body>

<script language="JavaScript" type="text/javascript">

var popupWindow=false;

popupWindow = window.open("about:blank");

if(!popupWindow){
  document.getElementById("pblock").value='blocked';
}

popupWindow.close();

document.all.blockdetect.submit();

</script>

</html>
Avatar of lenz8as

ASKER

John_Doe..
i have try ur suggestion.. but stil cant..
because when execute

popupWindow=window.open(..)

if the user's browser have pop up blocker, this statement still return an object..
so the statement

if(!popWindow){}
will not be executed ...

anyway, thanx... anyone can help me??
Ok, - did not test it...

What about this then:

1. Do not open about:blank, but a document that has a input with a value.
2. Check the value (if you got it)
3. Post

Ie:

Main File:

<html>

<head>
  <title>PopUp Check Window - Redirect</title>
</head>

<body>

<form id="blockdetect" action="page2.asp" method="POST">
  <input type="hidden" id="pblock" name="pblock" value="not_blocked">
</form>

</body>

<script language="JavaScript" type="text/javascript">

var popupWindow=false;
var areOpen=false;

popupWindow = window.open("someDoc.html");

var areOpen = popupWindow.document.getElementById('pblock').value;

if(!areOpen){
  document.getElementById("pblock").value='blocked';
}

popupWindow.close();

document.all.blockdetect.submit();

</script>

</html>

File 2(someDoc.html)

<html>
  <input type="hidden" id="pblock" name="pblock" value="true">
</html>
else, . i have no idea - might possible to get some more information from the popupWindow [object]..?
ASKER CERTIFIED SOLUTION
Avatar of COBOLdinosaur
COBOLdinosaur
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Agree that popup are a real pain - and I never use it for any solutions myself.

If the question was how to force popup or similar, I would never applied any suggestions.

However there are several occasions where detecting if user have a popup-blocker can be of some use for “legal” reasons.

Have used several systems developed for customer care and similar where they use popup to i.e. give the users choices that in turn are sent back to the opener page. And lot’s of other popup functionalities like process bars where code in popup do processes server side and so forth.

As mentioned I never use this sort of solutions myself, but one can be set to do minor changes in systems using this – and instead of saying “you have to enable popup to work this page” one can instead give other solutions for the user..

Br,
  -JD
Nothing you mentions there requires an unsolicited popup.  Thre are all kinds of alternatives to unsolicted popups, not the least of which is to launch the popup when teh user requsts it, but there are frames( including hidden frames), iframes, layers, and even continuous streaming using XMLHTTP.  None of which are disreputable enough that user demands have spawned a whole whack of products designed to prevent them from functioning.  

Popup blockers exist because 99% of popups are nothing less than abusvie and anything else that violates users rights with suffer the same fate.  Thank God for consumer activism, that keeps abuse in check.

Cd&
Well - as i said i never uses it myself but find other solutions.

What i meant was there are existing - in production - already made - coded by others - up running -.. or what ever ie Customer Care system using pop-up.
Of course the coders behind the existing system could have made better solution - but that's not always the fact.