Why isnt window.location.href= not forwarding to page using Safari?
Best way work in all browsers:
setTimeout(function(){document.location.href = "user_home.html";},250);
window.location.href on Safari and Chrome
window.location.href is not a function and therefor you cannot call it, you can however assign a value to it: (Also you should be using http:// when redirecting to another domain)
$(".myButton").click(function(){
window.location.href = 'http://www.blahblahblah.com';
});
EDIT: Corrected my first statement and added the part about http://
window.location does not work in Chrome and Safari
use
window.location.href
instead of
window.location
even better to use
The following works for me in current versions of IE, FireFox, Chrome, and Safari for Windows (fiddle = http://jsfiddle.net/MgX9U/)
window.location.replace("mailto:?subject=hi&body=content");
EDIT:
us setTimeout function before the second call, and make a delay for the second call.
Safari not opening a href with window.location.href
Try with either document.location.href
or just location.href
.
Hey there. Your code should work. Well i tried this simple example on Safari browser and it works good. Try yourself.
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
function countClicks()
{
window.location.href = "http://www.stackoverflow.com";
}
</script>
</head>
<body onLoad=countClicks()>
</body>
</html>
Anchor Property : FYI : I have used window.open
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
function countClicks()
{
window.open("http://stackoverflow.com", "_blank");
}
</script>
</head>
<body>
<a href="#" name="xy" onclick="javascript:countClicks(this);">Visit StackOverflow Website</a>
</body>
</html>
Passing variables from function
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
function countClicks(a,b)
{
window.open("http://stackoverflow.com?id="+a+"&id2="+b, "_blank");
}
</script>
</head>
<body>
<a href="#" name="xy" onclick="javascript:countClicks(2,3);">test</a>
</body>
</html>
Safari browser crashes on redirect window.location
Try window.open(pageurl);
window.setTimeout(function () {
var end = (new Date()).valueOf();
if (end - start < 1000) {
window.setTimeout(function () {
window.open(pageurl);//will be redirected to webpage crash is happening here
}, 5);
window.location = storeurl;
} else {
window.location = pageurl;
}
}, 5);
window.location = appicationurl;// will defaultly open application
Related Topics
Changing Svg Image Color With JavaScript
404 Error When Trying to Register Serviceworker
Prevent Sweetalert to Be Closed on Clicking Outside the Popup Window
How to Disable a Message When the Password Value Is Empty
Passing Variable from Button to Modal
How to Parse Excel (Xls) File in Javascript/Html5
Js Li Tag Onclick Not Working on Ie8
How to Highlight a Part of Text in Textarea
After Clicking a Button of Sweet Alert Call PHP File
How to Prevent Browser to Re-Set Inputs on Page Refresh
Chart.Js Showing Time (Hh:Mm:Ss - 24 Hour Clock) on Xaxis
Sequelize - How to Return Json Objects of the Database Results Only
Why Am I Getting Undefined as an Answer When Fetching Data from an API
Prevent Multiple Clicks .Click()
Angular 4 - Cannot Read Property Status of Null While Displaying Validation Error
Set Some Specific Options in Multiselect as Disabled and Selected