LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-25-2006, 02:14 PM   #1
true_atlantis
Member
 
Registered: Oct 2003
Distribution: fedora cor 5 x86_64
Posts: 639

Rep: Reputation: 30
javascript html link in a form to not reload page


is there a way to have a javascript link in a form that when you click it, it will not submit the form... here would be an example code

Code:
<form name='test' id='test'>
  <a href='javascript:window.open("http://www.google.com")GOOGLE</a>
  <input type=submit value='TEST' />
</form>
if you click that link, the original window will have '[object Window]' in it. there has got to be a way to get around this.
 
Old 10-25-2006, 03:59 PM   #2
Jaqui
Member
 
Registered: Jan 2006
Location: Vancouver BC
Distribution: LFS, SLak, Gentoo, Debian
Posts: 291

Rep: Reputation: 36
No idea, since I have javascript completely disabled as recommended by all the internet security groups out there for the last 2 years.

every site that "requires" javascript loses my business, or membership.
or flash for that matter.

"Active Clientside Scripting, such as Flash, Activex and Javascript are at best a SEVERE Security risk and should be disabled on every system"

Due to the total integration of Activex into windows, it is actually a Critical security risk to have Activex enabled in any web aware software.
 
Old 10-25-2006, 05:52 PM   #3
true_atlantis
Member
 
Registered: Oct 2003
Distribution: fedora cor 5 x86_64
Posts: 639

Original Poster
Rep: Reputation: 30
thanks for the security update... i agree, java is unsafe, but in some instances (in house projects) it can be very useful. in the future, if your going to start an answer to a question wiht 'No idea' dont bother. anybody else?
 
Old 10-25-2006, 10:50 PM   #4
pnellesen
Member
 
Registered: Oct 2004
Location: Missouri, USA
Distribution: Slackware 12.2, Xubuntu 9.10
Posts: 371

Rep: Reputation: 31
Something like this seems to work for me (I did this in about 5 minutes, so it's pretty raw ):

Code:
<html>
<head>
<script language="JavaScript">
function windowOpen(theUrl) {
 var newWindow = window.open(theUrl);
}
</script>
</head>
<body>
<form name='test' id='test'>
  <a href="#" onClick="windowOpen('http://www.google.com')">GOOGLE</a>
  <input type=submit value='TEST' />
</form>
</body>
</html>
 
Old 10-26-2006, 08:49 AM   #5
demon_vox
Member
 
Registered: May 2006
Location: Argentina
Distribution: SuSE 10
Posts: 173

Rep: Reputation: 30
It worked for me, but there was two characters missing. The ' closing the href string and the > closing the <a.
So the link will be like this:

Code:
<a href='javascript:window.open("http://www.google.com")'>GOOGLE</a>
alternatively you could try calling the open like this:

Code:
<a href='javascript:top.window.open("http://www.google.com")'>GOOGLE</a>
sometimes if there is a frame or something misterius that no one knows why affect the JS somehow. Yes, I dont like JS because it is a being with self conscius and selfawereness! (ok, maybe not, but it scares sometimes )

Hope this is useful.
Cheers!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Reload this Page Help with pakgen. Payload or data Packet_Crazy Linux - Networking 2 07-14-2006 08:01 AM
howto make html link to chrome:// page Brain Drop Programming 1 02-23-2006 02:15 AM
Can I "submit" an HTML <Form> with Javascript? nickiv Programming 3 06-13-2005 06:41 AM
konqueror: unwanted page reload problems salparadise Linux - Software 3 03-07-2004 08:33 AM
Creating HTML page with link in C jorgedf Programming 3 08-01-2003 02:47 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration