I have a website for which I have implemented livechat, when user clicks on livechat link it opens a new window that is fine. I want to do is when no operator is online then it should not open a new window when livechat link clicked instead it should redirect to the contact us page of the website in the same window in the currently opened tab, Is it possible?
I do not know how is it possible, what I have tried is this , it redirects to this page but opens in a new window.
window.location.replace('http://mywebsite.com/index.php?route=information/contact');
The problem is somewhere in the code around that. You need to call that code in the old window.
If you want to call it in the chat window, try:
window.opener.location.replace('http://mywebsite.com/index.php?route=information/contact');
window.close()
Use the href property instead:
window.location.href = 'http://mywebsite.com/index.php?route=information/contact';
You can use simple javascript code like this: window.location.href = "SOME URL"
it will do the same think. .
Related
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.
The following
button(type="button", target="_blank", onclick="location.href='auth/google';")
does not work. It opens link in the same window. Just for reference, its part of node.js program, in which i'm using passportjs for google authentication.
The button isn't actually opening a link - it's just running some javascript code that happens to, in this instance, be navigating to a new URL. So the target="_blank" attribute on the button won't help.
Instead, you need to use javascript commands to open a new tab/window, rather than using javascript to change the URL of the current window. Assigning to location.href will only change the URL of the current window.
Use the window.open(url, target) function instead - it takes a URL, and a target window name, which behaves the same as the target="whatever" attribute on a link.
window.open('auth/google', '_blank');
Your complete code would look like this:
button(type="button", onclick="window.open('auth/google', '_blank');")
I have a link that when clicked replaces the current page with another through the default <a> element click behaviour, but which also calls a JavaScript function to open another page in a new window. I would like the new window opened from my JavaScript function to appear behind the current window but can't figure out how to do this. In actual usage, I am feeding click thrus to a database, the link that is controlled by the window.open statement. The other link is to the clients site in a new window. I want the clients site to appear on top.
My current code is as follows:
<script language="JavaScript" type="text/JavaScript">
function countClicks(a,b)
{
window.open("http://stackoverflow.com?id="+a+"&id2="+b, "_blank");
}
</script>
test
So for the example URLs shown above I would like the (original) window with Google to appear in front of the new window with StackOverflow, but the new window always opens in front.
Try using window.focus() at the end of your existing function:
function countClicks(a,b) {
window.open("http://stackoverflow.com?id="+a+"&id2="+b, "_blank");
window.focus();
}
That should bring the existing window back to the front, noting that behaviour may vary between browsers and depending on popup-blocking settings, etc.
Or you could just swap the two urls, i.e., put the StackOverflow url in the href with the appropriate query string specified directly rather than in JS, and put the Google url in the window.open() call.
Popup behavior varies based on browser/user settings. I haven't been able to replicate the open behind behaviour myself, but I believe what you're looking for is .focus().
Try:
window.open("http://stackoverflow.com?id="+a+"&id2="+b, "_blank").focus();
I have the following javascript bookmarklet which opens a new popup window with a facebook post page in side of it.
javascript:var d=document,f='http://www.facebook.com/share',l=d.location,e=encodeURIComponent,p='.php?src=bm&v=4&i=1261526047&u='+e(l.href)+'&t='+e(d.title);1;try{if (!/^(.*\.)?facebook\.[^.]*$/.test(l.host))throw(0);share_internal_bookmarklet(p)}catch(z) {a=function() {if (!window.open(f+'r'+p,'sharer','toolbar=0,status=0,resizable=1,width=626,height=436'))l.href=f+p};if (/Firefox/.test(navigator.userAgent))setTimeout(a,0);else{a()}}void(0)
I just add that code into the URL of a shortcut link in my browser and it opens the facebook post page and passes the URL and some info about the page I am on to it.
I need to do a much simpler task. I need to get the URL of the page I am on and either open a new tab or even just use the tab I am in and then open a link like this
http://mydomain.com/labs/iframe_header.php?url= PUT THE CURRENT PAGES URL RIGHT HERE
As you can see I just need to make a bookmarklet that will take the page I am on and pass it into my sites page. Can anyone help me, I don't know much javascript at all, would greatly appreciate any help.
javascript: location.href = 'http://mydomain.com/labs/iframe_header.php?url=' + escape(location.href);
This will open in a new window, which will use a new tab if your browser is set up that way:
javascript: window.open('http://mydomain.com/labs/iframe_header.php?url=' + escape(location.href));
This is probably a simple question but I cannot figure out how to open the results from my database in a javascript popup window. I have an index.php page with a input box and an input button. When the user selects a date and presses the button, I'd like the results to open in a new window. How can I do this?
Thanks
I strongly suggest not doing this — http://diveintoaccessibility.org/day_16_not_opening_new_windows.html — but if you insist, then:
<form action="…" target="_blank">
This can be done with simple html:
Link Text
You need to open your new window using window.open. What you could do, is pass the date in as a querystring parameter to the URL that makes up the popup window page, and then use that parameter to perform the lookup from the database.
This page shows how to use window.open.
Use window.open to open another window. And than use this window to document.body.innerHTML your data.example
var wnd=window.open('','newWnd');
wnd.document.body.innerHTML="test"