draig_hand Posted September 4, 2009 Report Posted September 4, 2009 Hello all, I am trying to set up an onclick function in Javascript that opens another html file. Below there are a few examples of the code used and the error messages they received. Please note that it must be a button not a hyperlink and also it needs to be the genuine file that opens not a popup window. I cannot fathom why a simple request to open a file with a button should be such a problem! Can anyone assist please? THE FOLLOWING CODE function openFile() { file.open(C:\Documents and Settings\Administrator\My Documents\abbtweb\disclaimer.html) } GETS ERROR:- - line 145 Object expected (button line of code) ... THE FOLLOWING CODE function openFile() { file.open(disclaimer.html) } GETS ERROR:- - line 227 file is undefined (file.open line of code) ... THE FOLLOWING CODE function openFile() { file.open{C:\Documents and Settings\Administrator\My Documents\abbtweb\disclaimer.html} } GETS ERRORS:- - line 227 char 11 expected ; (file.open line of code) - line 145 Object expected (button line of code) ... THE FOLLOWING CODE function openFile() { window.open(disclaimer.html/) } GETS ERRORS:- - line 227 'disclaimer' is undefined (window.open line of code) ... THE FOLLOWING CODE function openFile() { window.open(/disclaimer.html/) } GETS ERRORS:- - line 227 Access Denied (window.open line of code) Quote
falkencreative Posted September 4, 2009 Report Posted September 4, 2009 Will this work for you? function openFile(){ document.location.href ="disclaimer.html"; } Quote
draig_hand Posted September 4, 2009 Author Report Posted September 4, 2009 Thanks Benjamin I'll give it a go and get back to you. Thanks again. Quote
draig_hand Posted September 4, 2009 Author Report Posted September 4, 2009 Thanks everyone The solution - i just needed to put quotes around it window.open("disclaimer.html") Thanks again. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
× Pasted as rich text. Paste as plain text instead
Only 75 emoji are allowed.
× Your link has been automatically embedded. Display as a link instead
× Your previous content has been restored. Clear editor
× You cannot paste images directly. Upload or insert images from URL.