I used Tinybox
http://sandbox.scriptiny.com/tinybox2/
to open a popup web page.
I hope when I click the links on the web page, the popup web page will close and automatically redirect to the link url I click
my javascript codes and html codes
<script type="text/javascript" src="tinybox.js"></script>
<script type="text/javascript">
function openJS(){}
function closeJS(){}
function closeAndGotoURL{
TINY.box.hide();
opener.location.href='http://www.google.com';
}
Open page2
//...below is on webpage2.html, it does not work
Click
but this looks like not to work
Instead of opener.location.href, use parent.location.href. See below:
function closeAndGotoURL {
TINY.box.hide();
parent.location.href='http://www.google.com';
}
You could also use top.location.href:
function closeAndGotoURL {
TINY.box.hide();
top.location.href='http://www.google.com';
}
Another option would be to use pure HTML. Although it wouldn't close the pop up first, it would redirect the entire window to your URL. Notice the target attribute of the anchor tag.
<a href="http://www.google.com" target="_top">
NOTE 1: Why close the pop up first? If you're redirecting the whole page, just redirect - no need to close the pop up.
NOTE 2: This will only work properly if the page that is loaded in the iframe is on the same domain as the parent window (I'm assuming that it is since you're writing the pop up code).
Related
I have a website-1 (www.example.com). When a customer reaches out to my website, the other website-2 (www.example2.com) should be open in a new tab corresponding with the website (www.example.com).
How to do this
I would like to add to Daan Teppema's answer.
Add rel property in the tag, if the website is not safe or untrusted add noopener. but if you are directing within your website remove the noreferrer for SEO tracking purposes.
Example 2
This will keep your website tab open and in the meantime open a new tab with the link you've provided.
You can do an <a> element with the target="_blank" attribute.
Like so:
Example 2
If you want them both to load, then you can make it go to the second one in another tab with javascript using the window.onload event.
Like so:
window.onload = function() {
window.open(url, '_blank').focus();
};
In my Billing CMS (WHMCS) there's a page that redirects you to another page.
The problem is that this redirected page is being opened as a Pop Up, and I'm looking for the source of it to make it open in target="blank" instead.
This is the redirect script I found in the page that originates the pop up:
<script language="javascript">
setTimeout ( "autoForward()" , 0 );
function autoForward() {
var submitForm = $("#submitfrm").find("form");
submitForm.submit();
}
</script>
Can this function trigger the Pop Up? Is there a way to change it to _blank by adding something to the code above? If not, what should I look for to find the source of this function?
Thanks!!
If you have control over that function, set the form's target
function autoForward() {
var submitForm = $("#submitfrm").find("form");
submitForm.prop('target', '_blank');
submitForm.submit();
}
Here is the documentation on target.
Trying to open a link in a framed page and close the child window. The link bellow is in a child window and when I click it opens the link in the framed page, but did not close the child window
<a target="Resultado" href="?Tela=1"
onClick="javascript:return confirm('TryMe');window.close();">
I have used a code like this to close the window... but couldn't get it to work with the above code.
<a href="javascript:window.opener='Resultado';window.close();">
Try this:
<a target="Resultado" href="?Tela=1" onclick="clickHandler(event, this);">Link</a>
And declare this:
function clickHandler(e, el) {
var choice = confirm('TryMe');
if (!choice) {
e.preventDefault();
}
window.close();
}
I wasn't sure of your original use of window.close() since it came after the return and would never execute, so it's up to you to move it to where you want.
Create another webpage on your webserver & use that as the Custom URL thankyou page for your form.
In that new webpage have just one line of code.
<body onload="javascript:window.opener.childClosed();window.close();">
--
That code will call a javascript function in the parent window and then close the child popup; you can then use that javascript function to do a redirect on your parent page.
I am not to sure where the URL of your 'Thank you for requesting...' page is, but here is some javascript to redirect to google on your parent page after the form is submitted.
function childClosed() {
window.location = "http://www.google.com/"
}
You can put that script before your closing <body> tag.
--
Hopefully I have understood your query OK, let me know if you have any questions or need any clarification on this possible solution.
-
I have made a very basic clone of your webpage & form here if you want to test out the functionality, 'Factoring Question?' is the link that contains this code.
I want to link to an amazon music preview player as an popup from my site. I have this code:
Link
My Problem is, when I click on the Album Cover in the Amazon Popup, my parent site with the link refreshs with the target Amazon url. When I open the Popup URL by typing the url in the adressbar and then click on the cover, a new window is opend with the target url (this is what I want to force).
Is it possible to don't pass the parent relation with the link popup window?
Make sure you are not using "popper" as the identifier for both instances of winow.open. The main one that opens the initial popup should be different from the one that is inside the popup itself, unless you want it to change the popup that is already open (in which case, the window.open in the onclick attribute is essentially unnecessary).
What I mean is by this:
Say you are launching the original popup with the code in question like this:
Popup
And the popup with the code in question is this (popup.html):
Link
You need to make sure the original popup identifier is different from the one in the popup. So, the original popup should be something like:
Popup
I solved my Problem using something like this:
Open a local popup.php from my site with JS while passing amazonurl as var.
<a onkeypress="window.open(this.href,'popup','scrollbars=1,width=900,height=600'); return false;" onclick="window.open(this.href,'popper','scrollbars=1,width=900,height=600'); return false;" rel="nofollow" target="_blank" href="http://domain.com/popup.php?amazonurl=http://[...]">Link</a>
In popup.php I use
<script language="javascript" type="text/javascript">
window.opener = null; window.location.href = "<?php echo $_GET['amazonurl']; ?>;</script>
To make windpw.opener = null and then refresh the popup with the amazon URL.
the link
<script type="text/javascript">
goog_report_conversion_website = function() {
$('#converstion_tracker_iframe').attr('src', '/conversion_tracker/website/');
}
</script>
The expected behaviour of above link should be open up the link in a new window and execute the 2 js functions. However, the goog_report_conversion_website() function is causing the parent page to reload while opening up a new window.
I suspect this is because I am changing the DOM of the parent page, could anyone please confirm with me? Also how to stop the parent page reloading on clicking the link?
EDIT:
looks like change the src of an iframe will cause the page to reload
Did you try adding return false like this?
the link