views:

87

answers:

3

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>
A: 

you could have a small timer on your page with a 1 second time out.

MasterMax1313
but how do i know when javascript is enabled? will all <script> tags run automatically?
Garrett
+5  A: 

not realy a good ide, but i think it would work:

  • set a meta-refresh of 5(?) seconds on your first page and:
  • set a javascript-redirect to your second page (window.location.href='...')

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.

oezi
yes but if not the user is stuck on a page which reloads every 5 seconds!
seengee
if i understand the question correct, page1 is only a "please enable scripts, dude!"-page, where there is no problem with a 5-second-refresh
oezi
maybe yeah, nothing in the question to actually suggest that is the case though.
seengee
good idea! maybe instead of 5 seconds i'll do 60 seconds so they have a chance to read and follow the instructions on how to enable javascript. thanks!
Garrett
@seengee: but nothing suggests it's a complex page where you can't do so, too, so i expected easy conditions
oezi
@oezi true - both solutions would work but i still prefer mine :p
seengee
+3  A: 
seengee
this is good too! i'll have to try this out and see if it works, because it is better than refreshing the entire page rather than an invisible iframe. thanks!
Garrett
doesn't work yet. i've updated my post with the deets =)
Garrett
@Garrett - the iframe needs to link to an actual file using its src attribute - see example above
seengee
thanks a lot! i've never used an iframe before. this is actually amazing! good thinking, seengee!
Garrett