Close current window when it call Open Tel: - javascript

When I call window.location.href("tel:"+'+0060199999') it will open the Skype which is working fine.But i dont want current browser window stay open, i want to close it.If i put close, it is not even open the Skype.Is this possible to do?
<html>
<script>
window.onload = function () {
window.location.href="tel:+0060199999";
window.close();
}
</script>
<body>
Let me test
</body>
</html>

Related

Logout once the Browser is Closed

I'm trying to record user sign out time in mysql DB once he close the browser. I searched for it but the most articles talking about window.onbeforeunload JavaScript event, but doesn't work with all browsers. even it works with F5 button can't specify massage or action,.
<!DOCTYPE html>
<html>
<body onbeforeunload="return myFunction()">
<p>Close this window, press F5 or click on the link below to invoke the onbeforeunload event.</p>
test by redirecting
<script>
function myFunction() {
return "specific massage";
}
</script>
</body>
</html>

Add a delay to existing code?

I am trying to create an HTML file that when run, will open a URL in a new tab (the URL is pointing to a file on a local server, so when the HTML is run it in fact prompts the user to open or save the file), and then after x seconds, closes itself without the prompt asking the user if they wish to close the tab.
Only Internet Explorer can be used, as my company does not allow other browsers.
I already have a file that opens and closes the tab, however, the tab is closed almost immediately, which does not allow time for the prompt to come on-screen and ask the user if they wish to open or save the file. Here is my code so far:
<html>
<head>
<title>You are being redirected</title>
<meta HTTP-EQUIV="REFRESH" content ="0; url=X:\\Directory\Subdirectory\File.docx">
</head>
<body>
<center>
<script type="text/javascript">
window.open('javascript:window.open("", "_self", "");window.close();', '_self');
</script>
</center>
</body>
</html>
A solution to my problem would be to just literally add a delay between the tab opening and closing in the above code (ideally 5 seconds or 5000 milliseconds). If anyone could show me how to add this delay before it closes that would be extremely helpful.
<script type="text/javascript">
setTimeout(function() {
window.open('javascript:window.open("", "_self", "");window.close();', '_self');
}, 5000);
</script>
You should use settimeout():
setTimeout(function,milliseconds,param1,param2,...)
Read about it here: w3schools settimeout();
This works to open a new tab and close it after 5 seconds
var wnd = window.open("http://google.com", "_blank", "");
window.setTimeout(closeWindow, 5000);
function closeWindow() {
wnd.close();
}

Javascript window close

I need to get a custom alert box when user clicks on 'X' (window close).
User is given 'OK' and 'Cancel' button options
OK button closes the window. Cancel button cancels the close action
I think you may find your answer on this post which looks similar - javascript confirm dialog box before close browser window
You have to show what you have done so far
Html code
<html>
<head>
<script type="text/javascript">
window.onbeforeunload = function() {
return "Did you save your stuff?"
}
</script>
</head>
<body>
</body>
</html>

How to call a function when close popup window

I am calling the Javascript window.open() function to load another url in a pop up window.
When the users closes the popup window, I want the MyThanks() function to be called. How I can do this?
My Script :
<!DOCTYPE html>
<html>
<head>
<script>
function openWin(){
myWindow=window.open('http://facebook.com/ekwebhost','','width=600,height=400,left=200');
myWindow.focus();
}
function MyThanks(){
alert("Thanks");
}
</script>
</head>
<body>
<input type="button" value="Open window" onclick="openWin()" />
</body>
</html>
Regarding usage of popups:
Are you aware that Facebook & Twitter still use popup windows for user like & follow. Go to http://www.ekwebhost.com and click the Facebook "Like" button or the Twitter "Follow" button. Why can't I use popup windows for my own needs?
function openWin(){
myWindow=window.open('http://facebook.com/ekwebhost','','width=600,height=400,left=200');
// Add this event listener; the function will be called when the window closes
myWindow.onbeforeunload = function(){ alert("Thanks");};
myWindow.focus();
}
Try this!
You can swap out the function(){ alert("Thanks");}; for MyThanks to call your function.
The new window that you open will have an attribute called opener that references the Window object that created it. You can then call functions on the parent window by calling window.opener.MyThanks();
Popup:
<script type="text/javascript">
function closePopup() {
window.opener.MyThanks();
window.close();
}
</script>
<div>
<h1>My Popup</h1>
<!-- Form or info to display -->
<button onclick="closePopup();">Close</button>
</div>
While there is nothing inherently wrong with browser popup windows, they can be annoying since the user can lose them behind other windows. Also, it takes their focus off of your page to do something else. The application that I currently develop is trying to move all of our popup windows to Javascript dialogs. It gets pretty annoying for users once you get 3 popups deep.
There are a bunch of ways to create dialogs within your webpage. jQuery UI is one library that I like.
You can try this:
<script>
function openWin() {
myWindow = window.open('http://facebook.com/ekwebhost', '', 'width=600,height=400,left=200');
myWindow.focus();
MyThanks();
}
function MyThanks() {
alert("Thanks");
}
</script>

Javascript redirect - New Window

I'm trying to create a re-direct using Javascript from inside a blank iframe that will direct to a URL inside a new window or tab.
More specifically, I'm trying to make a Facebook tab point to my company's webpage rather than load the page inside the tab's iframe which is not the same width as our web page.
Here is the redirect script I already have but it doesn't open the URL in a new window.
<script language="JavaScript">
<!--Redirect to 75th page
var time = null
function move() {
window.location = 'http://philmontscoutranch.org/Camping/75.aspx'
}
timer=setTimeout('move()',0000)
//-->
</script>
Ok - This snippet will open a new window when the page loads but Chrome's pop-up blocker blocked it. I didn't think about this until now. Maybe I could have it load in a light window?
<script language="JavaScript">
<!--Redirect to 75th page
var time = null
function open_win()
{
window.open("http://philmontscoutranch.org/Camping/75.aspx", "_blank");
}
timer=setTimeout('open_win()',0000)
//-->
</script>
Here you go: Jsfiddle Example
function opennewtab(url){
var win = window.open(url, '_blank');
}
<html>
<head>
<script>
function open_win()
{
window.open("http://philmontscoutranch.org/Camping/75.aspx", "_blank");
}
</script>
</head>
<body>
<input type="button" value="Open Window" onclick="open_win()">
</body>
</html>
Source

Categories