![]() |
redirect using javascript
I am trying to redirect a page to another using this code:
Code:
function GoToURL() {But now it doesn't work! Is it obvious what is wrong? |
take out the this.
|
I think location is the reserved keyword for JavaScript. Hence you can not use it as a variable name. Try to change the local variable name and also (remove this keyword).
|
Quote:
|
Thanks, I tried both ideas but no luck.
I have this: Code:
<html>Is something above not compatible with Chrome and FF? |
location.href = "http://google.com.au";
|
But location.href doesn't work either.
I suspect that there is a problem trying to change the page from within the checking part of the form submit. Could that be it? Does the form submit have to complete? |
AHA! See how it helps to show the *COMPLETE AND REAL* problem!!!
The culprit is *HERE*: Code:
<form method="post" name="logonform" onsubmit="check_form()">Since you don't specify any action= in your <form> tag, that means the the submit will now take you RIGHT BACK TO THIS SAME PAGE!!! If you do *NOT* want the submit action to happen, you *MUST* return false from the onsubmit= So: Code:
<form method="post" name="logonform" onsubmit="check_form(); return false;"> |
As an alternative:
Code:
<form method="post" name="logonform" onsubmit="return check_form()">Code:
function check_form( ) |
drive letter check
I have a script which determines the drive that a CD or DVD is playing from (obviously within Windows).
This little piece of code must reside on the disk in a file called drive.js: Code:
var driveletter=a[i];Code:
<script>The driveletter can be read back with this: Code:
// use this script in those pages where you want the driveletter's valueIs there a way to have the driveletter check take place within an external .js file? How can the bit below be done within a .js instead of html? Code:
... |
Gloom. I messed up.
This is meant to be in a new post. Sorry. |
Quote:
Code:
var loadJS = function(nm) { |
You are amazing! Thank you.
|
Since this is for windows, there is a much easier way if you are willing to use MSIE only:
Code:
function findDriveThatIsPlaying( ) |
I think Felgall missed the end of his answer.
Shouldn't it be: Code:
var loadJS = function(nm) {But I still think that's not the best way, given that this is for Windows only, MSIE only. |
| All times are GMT +1. The time now is 09:27 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.