Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

invoke javascript function from http link?

Status
Not open for further replies.

clarkmurray

IS-IT--Management
Nov 9, 2002
35
US
I have an html page with a link on it that invokes a javascript function [javascript:movienew('Preview')]. Is there any way I can create an http link that invokes that function directly, without having to go to the page first?
 
Do you mean
Code:
<a href="#" onclick="movienew('Preview'); return false;">Preview</a>

--Chessbot

"Violence is the last refuge of the incompetent." -- Asimov, Foundation
 
I don't understand the question.

Two ways to call a JavaScript function via an anchor tag (hyperlink). Either set the href equal to "JavaScript:functionName()", or set the href equal to a target instead, and provide an "onclick='functionName()'" property.



Thomas D. Greer

Providing PostScript & PDF
Training, Development & Consulting
 
Sorry, let me try again. Currently I have a page:


That page contains the statement:

<a href="javascript:movienew('Preview')">What's New in Cubase SX 3?</a>

I would like to be able to publish a link to be posted on other websites which can invoke the javascript function directly from the other site. Something like:

[???whatever???]javascript:movienew('Preview')

Is that possible?
 
Not easily.
You could open the page in a frame or new window and call it there, but the best way would be to copy and paste the function.

--Chessbot

"Violence is the last refuge of the incompetent." -- Asimov, Foundation
 
>...
><body onload="myFunction();">
>You would write a page as above. Referrers would link to that page.

Thanks. Works fine in IE. Unfortunately I was not able to get it to work in Firefox. 9% of my website visitors use Mozilla/Firefox.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top