Forum Moderators: open

Message Too Old, No Replies

JavaScript Fake Links

how do I make a link that will run but not change the page

         

wfernley

7:20 pm on Apr 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I currently have a page that has links that when clicked, send commands to a CGI file. The problem is the link goes to the CGI file. The quick fix I have setup is I created the page in frames and the link is associated with a hidden frame. That way, when the link is clicked, it sends the command to the CGI file but does not change the main page but instead changes the hidden frame.

Hope that makes sense ;)

Is it possible to create a link in JavaScript that does the same thing but without the frames?

Please let me know if you need further clarification.

Thanks!

Wes

Dabrowski

10:51 pm on Apr 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, a link's entire purpose is to go somewhere. I believe the way you have it set up is the best way.

If you want the CGI to actually display stuff on screen you may want to look at using AJAX to cann your CGI and then fill in a screen area.

Drag_Racer

7:52 am on Apr 27, 2007 (gmt 0)

10+ Year Member



yes, very simple to do.

<script type="text/javascript">

function sendIT(param){
var URL = "/pathto-cgi-bin/cgiscript.cgi?"+param; //change this path to your script
var request = false;
if (window.XMLHttpRequest){
request = new XMLHttpRequest();
}
else if (window.ActiveXObject){
try{
request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
request.open("GET", URL, true);
request.send(null);
}
</script>

anchor...

<a href="javascript:sendIT('your-commands');">something...</a>