adcash like site under pop up in new tab - javascript

i have seen adcash.com site under pop up/new page which is opened by every browser in new tab without any issues.i tried searching everywhere but could not find how to open a website in new tab without affecting the current webpage.
if you have used adcash.com site under script you might have noticed that when you click on next or any link one complete webpage will open in new tab and your present page will not at all affected.
plz help.i want to open ndtv.com in new tab not in new window but when users click on next page link that page should open there itself but ndtv.com should open in new tab.it means it has to work as usual and open next page in parent page plus new page in new tab.

According to what you said in the comments I think you are searching for something like this:
Click
What this will do is: Whenever you click "Click" it will go to where-you-want-to-go.php, and in the mean time it will open up google.com in a new tab.

Do two actions with one link.
<a target="_blank" href="http://www.google.com" data-location="http://www.example.com">Google</a>
$("a").on("click", function () {
window.location.href = $(this).data("location");
});

Related

JavaScript behavior change depending on how page is loaded

I am having an issue where seemingly the way JavaScript executes is changing depending on whether I open a file from a brand new browser tab (copy-pasting the link in) versus if I open the page by clicking a link from another page.
A summarized version of my code is:
<html>
<head>
<script>
try {
// ...other code...
throw new Error("error");
} catch (e) {
location.href =
"https:\/\/google.com"; // would be "https:\/\/mysite.com"
}
window.close();
</script>
</head>
</html>
If I open this in a brand new tab by copy-pasting the link, the tab will navigate to https://google.com
However, if I open the link via a hyperlink, the new tab closes immediately.
Ideally, I want the redirect to be successful regardless of how the page is loaded.
Would love to understand what's going on here as the above code snippet is from an external library that I can't modify
Appreciate any insight or help!
From MDN:
This method can only be called on windows that were opened by a script using the Window.open() method, or on top-level windows that have a single history entry. If the window doesn't match these requirements, an error similar to this one appears in the console: Scripts may not close windows that were not opened by script.
In other words, a page opened by clicking a link on another site cannot use window.close(). However, if you create it with window.open(), that restriction does not apply and you can use window.close(), which is overriding your redirect. Ctrl clicking on a link to open it in a new tab also satisfies this condition. You can verify that by running window.close() in the devtools console and seeing whether or not it closes the tab.

href target tab should open a tab in first and update on second time

I am quite new to HTML, I have senior where I have two anchor tags in one HTML page.
Example:Main.html
Google<br>
facebook
My goal is to open Facebook or Google in a new tab when the user first clicks a link.
When the user clicks a link again, it shouldn't open a new tab, but instead it should update the Google or Facebook tab that has already been opened.
Set your target attribute.
<a href="https://www.facebook.com" target="facebookTargetTab" />Facebook</a>
Links with the same target will open up in the same new tab. This behavior is a holdover from the days of framesets, where each frame was named. If the name didn't exist, a new window (and these days, a new tab) was opened.

Open a javascript advertising code when click on a another url link?

My question is I want to open a advertisement but condition is .. when i click on data url
at that time data url opened also with another new window advertisement also open.
So how i write a code so open two page : one my content(data) page and another is
advertisement page..
Please give me a answer for my problem.
Run an onClick="function()" and a link.
<div onClick="openAd()"></div>
<script>
var function = openAd(){
window.open("ad");
}
</script>
Here I use window.open(), which does what it sounds like and opens a new window with the link.

Iframe open page links in new tab

I just need one thing. How to make "iframe page" to open their links in new tab.
I try to add target="_blank" but I think that is not iframe attribute.
My code open one webcam site. I want, when someone click on "sign up" to be opened in new tab...
The only real solution is to either have target="_blank" bound to specific links, or if you control the page that you're loading in the iframe, making sure that page has a <base target="_blank"> element on it, which makes all a elements link through a new tab/window
What's wrong with target="_blank"? It works no matter where the link is.
do you mean " links that are in a page that is loaded in a iframe" ?
if so , I'm not sure such a thing exists in html 4 . it depends on browser I think . firefox , chrome , opera open _blank in new tab but IE opens it in new window

open link out of iframe

I'll try and keep this short. I have a page with various section. One section has an iframe with a google map in it. On the infowindows i have a link which when clicked i would like it to open in a fancybox over the page(not in the iframe...i can do that). For example if i had a link saying "google", id like it to open http://www.google.co.uk/ over the whole page in a fancybox.
I have 2 different pages and 2 javascripts, 1 for the map(iframe) and another for the main page. The function is in the main page script.
Where i think im going wrong is a) the right call to open the page b) attaching a class to the javascript i.e class="fancybox".
My map info window has this link in it(map.js):
some content
In my main.js:
function openSomething() {
//this is where i think im going wrong
//ive tried window. and top. etc
var url = "http://www.google.co.uk/";
document.location.href = url
};
My call to the fancy box is in the main page.
Any help would be much appreciated.
No need to use JavaScript: set the desired link as the href attribute, and use the target attribute to define where it is opened.
target="_top" will open the new link in the entire page
target="_parent" will open it in the parent frame or page
target="_blank" will open it in a new window.

Categories