I have a site that pop's up the receipt for a transaction after the sale is complete using a window.open javascript call. However, if pop-ups are disabled, the receipt does not get displayed, and I'd like to detect this so I can display the information differently.
Something like this: //Display receipt window with instructions to print it.. if ( Request.Browser.JavaScript == true ) { Response.Write("<script>"); Response.Write("var w; var h; w=480;h=640;if(window.screen){w=window.screen.availWidth/2;h = window.screen.availHeight;}");
Response.Write("var opengood = window.open('receipt.aspx',null,'scrollbars,resizable,menubar,width=' + w + ',height=' + h + ',top=0,left=0');"); Response.Write("if(!opengood){popUpsBlocked = true;}"); //popups were disabled, use the non-popup way of displaying
receipt Response.Write("</script>"); } if ( (Request.Browser.JavaScript != true) || (popUpsBlocked == true) ) { LabelErrorStatus.Text = "Order Completed ( Order Id = "+ tempInt +"). Print this screen for your records." ; LinkButtonReturn.Visible = true; }
It does compile, but I'd bet it doesn't work because I'm setting a C# variable inside the javascript block.. not a valid thing to do i don't think. Anyone know of another way to detect disabled pop-ups on client browsers? Or could I somehow set the popUpsBlocked
in some other way that I could use it in C#? Brent
let's think about this shall we. 1. popup blocking and bypassing such blocking is an arms race between advertisers and software vendors. do you really want to get into an arms race? you'd have to change your code every time a popup blocker is updated, and that's
surprisingly often - this of course is besides getting the bypass code to work in the first place. if these things were that easy to bypass, their developers would be out of business pretty quickly - they've got a vested interest in stopping you doing what
you describe. 2. why does it need to show in a popup? 3. user-initiated popups are never blocked. provide a text link which says 'no reciept? click here!' 4. why does it need to show in a popup? 5. the code you've shown is all very well, but it's a dead-end.
you NEED to allow user intervention if popups are disabled. 6. why does it need to show in a popup?
RTFM - straight talk for web developers. Unmoderated, uncensored, occasionally unreadable
The receipt appearing in a popup, to me, seemed like a clean and informative way to tell the shopper that their order has been made. I wanted to redirect them back into my store automatically in the main window.. but at the same time let them know they've already
made one order, so no need to repeat it if they 'weren't sure' it completed. Also, by popping up a new seperate window with minimal toolbars on it (ie, i just have the top toolbar, and no navigation buttons enabled), it makes it more straightforward how to
print their receipt.. something us experienced e-commerce users often take for granted. I suppose I will now simply bring the receipt page up in the main window, then add a 'return to store' button once it's confirmed in the receipt page. This adds a lot of
code re-writing and testing to my project, but I guess it's my only choice. Thanks a lot Google for adding a days' work to my website. :P Brent
big_jim_mcbo...
Participant
1245 Points
249 Posts
Pop-up disabled detection
Nov 28, 2003 05:16 AM|LINK
Atrax
All-Star
18705 Points
3733 Posts
Re: Pop-up disabled detection
Nov 28, 2003 06:26 AM|LINK
Jason Brown - MVP, IIS
big_jim_mcbo...
Participant
1245 Points
249 Posts
Re: Pop-up disabled detection
Nov 29, 2003 08:55 PM|LINK