Solved

JavaScript to open a link in an iframe and PopUp Blockers

Posted on 2004-08-23
5
391 Views
Last Modified: 2008-02-01
Hello,
  I need to open a link in an iframe to do some server validation and redirectthe user to a different location in a new window.
So on click of the submit button, I do some javascript validation and then within the function
document.DataFrame1.location = "action_server_validate.asp?ml_num=" +  d.ml_num.value ;

The action_server_validate generates code to submit a form to an external website with arguments target="_blank"
which is blocked by pop-up blockers.
What are the workarounds...

One way I presume is to substitute the above statement to

window.open("action_server_validate.asp?ml_num=" + d.ml_num.value) ;


anything else...

Thx!
0
Comment
Question by:danths
5 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 300 total points
Comment Utility
Instead to target the respnse to _blank you could target it to a previously opened popup.
The target name is the second parameter in window.open() call.
Like this:

window.open("", "newWin");
document.DataFrame1.location = "action_server_validate.asp?ml_num=" +  d.ml_num.value ;

Now when your action_server_validate.asp set the targe="newWin" will the popup be populated with the response.



 
0
 
LVL 15

Expert Comment

by:Thogek
Comment Utility
Is there a reason why target="_blank" is currently being used?  (Is the opening of a new window necessary?)
0
 
LVL 3

Expert Comment

by:Ayesha_K
Comment Utility
not sure if i'm understanding the problem correctly or not ... but if your browser is not allowing pop-up windows then it wouldn't allow to open you a new one no matter what the name of the window will be ... i mean your page WILL open a new window ... but the user's browser wouldn't let it get displayed ... this is a user's browser setting ... and you can set it  open pop-ups for your own testing purpose but u can't restrict user to view a pop-up even if he has blocked pop-ups.
0
 
LVL 6

Author Comment

by:danths
Comment Utility
Yes, it is necessary to open the url in a new window.


Ayesha:- I did some basic reading on how these pop-up blockers work, and the difference is that they allow a new window if the user intentionally does an action like click a button or url etc.

Zvonko:- Isn't the net affect of your suggestion the same as
window.open("action_server_validate.asp?ml_num=" + d.ml_num.value) ;
0
 
LVL 15

Assisted Solution

by:Thogek
Thogek earned 200 total points
Comment Utility
Depending on the popup-blocker softwares involved, most should allow a popup window to appear if the context of the attempt to open the window is a mouse-click event.  I wouldn't guarantee that they all work that way, but by now, I believe that most of 'em do.

> The action_server_validate generates code to submit a form to an external
> website with arguments target="_blank" which is blocked by pop-up blockers.

Can we get a clearer idea as to exactly what action_server_validate is doing?
It *sounds* like action_server_validate is generating an HTML page with an HTML form with target="_blank", and auto-submitting that form via embedded JavaScript (either inline or in an onload handler).  (I'm guessing based on what you've said above; please correct me if this is incorrect.)  If this is so, then the context of the attempt to open the window is a page's onload, *not* a click event, and popup blockers *will* block that.

Have you tried, as you suggested, replacing the initial document.DataFrame1.location assignation with a call to window.open?  (In such a case, the window.open call would be within a click/submit event, and should be allowed by most popup-blockers.)  If so, does that work?
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
jquery, dropdown 4 34
Where to begin studying? 5 63
Change properties of a dialog box 1 19
Problem to page 4 16
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now