How do you script a link to both click to a popup and redirect the page in the browser?
-
Building a web app in which the user clicks a link to do something that occurs in new window that opens. I'd like the main page in the browser, where someone clicked, to also change, to a "confirmation page" on the same domain. Simple onclick script, no? I hoping this isn't a sophisticated coding question but that a straightforward script exists. How would I rewrite <a href="link to which I'm sending user">anchor text</a> to not just direct the click to the one new page but another page on a new domain in a popup while refreshing the browser with the page on the same domain?
-
Answer:
<a href="http://www.example.org" onclick="window.open('http://www.google.com','newwin');">click me</a>
Paul O'Brien at Quora Visit the source
Other answers
You are asking a very vague question w/o any additional information e.g. whether the content that you load in the new window would be served from the same domain? Are you using any navigation framework? Would the "confirmation screen" reside as a separate REST resource (If not, then we can use show/hide to display that)? I will try to answer it based on assumptions. Have a javascript function execute bind to on click event on the DOM element of your choice. The function should do the following:- 1. Use https://developer.mozilla.org/en-US/docs/Web/API/Window.open to open a new tab passing in the data required to render that page. 2. Use https://developer.mozilla.org/en-US/docs/Web/API/Window.location to navigate your current page to "confirmation screen".
Divij Vaidya
The href attribute of the link should point to the page you want to navigate in the current window. And write window.open in a js that gets triggered onclick of this link. Window.open should point to the page you are looking to open in popup
Anurag Ashok
Related Q & A:
- How do you make a link into a clickable picture?Best solution by Yahoo! Answers
- When i do a search and click on a result a get a page addressed rc10 overture what do i do?Best solution by Yahoo! Answers
- How do you put a link to a picture in your question?Best solution by Yahoo! Answers
- How do I save a link to my browser?Best solution by Answerbag.com
- How do you add a link to a photo on a question?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.