i was wondering if there was some sort of event triggered when javascript is enabled in a browser (ie. in firefox, tools->options->check off enable javascript-> click ok). i want to redirect a user to a page when this happens. any ideas?
Thanks!
EDIT: i've put an iframe into the page but am not getting the alert (after i enable javascript), so the refresh must not be working. what is wrong with this?
<iframe style="display:none">
<html>
<head>
<title>my iframe</title>
<meta http-equiv="Refresh" content="5" />
<script type="text/javascript">
window.parent.location.href = 'home.php';
alert("HELLO");
</script>
</head>
</html>
</iframe>
To redirect to another page in JavaScript, you can use window. location. href property, window. location will also work and if you want you can use window.
In Javascript, window. location function is used to redirect to a URL.
To redirect one HTML page to another page, you need to add a <meta> tag inside the <head> section of the old HTML page. The <head> section of an HTML document contains metadata that is useful for the browser, but invisible to users viewing the page.
not realy a good ide, but i think it would work:
as long as javascript is disabled, the user stays on page1, where every 5 seconds the refresh is triggered... if javascript gets enabled, on the next refresh the js-redirect is done so the user gets to page2.
You can only detect whether JavaScript is enabled/disabled on page load. There is no event called for it being enabled/disabled after a page has loaded. Only possible solution i can think is to have an invisible iframe in your main page containing a script with a small meta refresh and a check for whether JavaScript is enabled - if it is then redirect the parent(main) page.
so your iframe would include something like this:
jscheck.html
<html>
<head>
<title>my iframe</title>
<meta http-equiv="refresh" content="5">
<script type="text/javascript">
window.parent.location.href = 'js_turned_on.html';
</script>
</head>
<body>
</body>
</html>
checker.html
<html>
<head>
<title>Form Test</title>
</head>
<body>
<iframe src="jscheck.html"></iframe>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With