xProteuSx Posted December 19, 2009 Share Posted December 19, 2009 Usually I can figure this out, but I am completely stumped. Say I have a function like this: whatever = new function() { alert("Yay"); } Then I have a link like this in the HTML: <a href="javascript:whatever()">Say Yay!</a> Why does this not work for me???? Please help! Thank you in advance. Quote Link to comment Share on other sites More sharing options...
xcoderx Posted December 19, 2009 Share Posted December 19, 2009 Usually I can figure this out, but I am completely stumped. Say I have a function like this: whatever = new function() { alert("Yay"); } Then I have a link like this in the HTML: <a href="javascript:whatever()">Say Yay!</a> Why does this not work for me???? Please help! Thank you in advance. try it this way function func_name() { alert("yay"); } <input type="button" value="Say Yay" onClick="func_name();"/> Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted December 19, 2009 Author Share Posted December 19, 2009 xcoderx, I cannot use a button ... it must be an <a href=""></a> thing because I am using an image as the button. Any ideas? Quote Link to comment Share on other sites More sharing options...
xcoderx Posted December 19, 2009 Share Posted December 19, 2009 try this <a`href="#" onClick="func_name();"/>Say Yay</a> Quote Link to comment Share on other sites More sharing options...
xcoderx Posted December 19, 2009 Share Posted December 19, 2009 ok here done function func_name() { alert("yay"); } <A HREF="#" onClick="func_name();"> Say Yay </A> Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted December 19, 2009 Author Share Posted December 19, 2009 Thanks for your help xcoderx. I have tried these things already, but it turns out that I was doing this correctly. I have narrowed it down to this: one of my variables is not assigning: var outputString = '<table width="650" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="300"> <a href="http://www.amazon.com/Disciplined-Breakdown-Collective-Soul/dp/B000002JCB/ref=sr_1_1?ie=UTF8&s=music&qid=1261206207&sr=1-1"> <img src="img/cover_disk_disciplinedBreakdown.jpg" border="0" /> </a> </td> <td width="25"></td> <td> <font class="title">Disciplined Breakdown</font> <br /><br /> 01. Precious Declaration<br /> 02. Listen<br /> 03. Maybe<br /> 04. Full Circle<br /> 05. Blame<br /> 06. Disciplined Breakdown<br /> 07. Forgiveness<br /> 08. Link<br /> 09. Giving<br /> 10. In Between<br /> 11. Crowded Head<br /> 12. Everything<br /> </td> </tr> </table>'; Any idea why outputString = '' ?? Quote Link to comment Share on other sites More sharing options...
xcoderx Posted December 19, 2009 Share Posted December 19, 2009 where are the brackets? ()? Quote Link to comment Share on other sites More sharing options...
xProteuSx Posted December 19, 2009 Author Share Posted December 19, 2009 Man, everything I tried the first time works, but it was out of sequence. I have it all figured out. Thanks a ton xcoderx. If you're still around, here is my final question: is there a way to have a link with an onclick clause that goes to a different page and runs a function on that page? For example: I am on index.html where there is a link that looks like this: <a href="about.html" onclick="javascript:runme()">About</a> If you click the link it takes you to the about.html page and runs the function runme() which is scripted on that page. Is this possible? Quote Link to comment Share on other sites More sharing options...
nafetski Posted December 20, 2009 Share Posted December 20, 2009 Unless that page is an iframe, you will have to pass the new page a variable via $_GET <a href="newlocation.php?executefunction=true" >Click here</a> Then on the new page <?php if(isset($_GET['executefunction']){ // Do something } Quote Link to comment Share on other sites More sharing options...
xenophobia Posted December 21, 2009 Share Posted December 21, 2009 Man, everything I tried the first time works, but it was out of sequence. I have it all figured out. Thanks a ton xcoderx. If you're still around, here is my final question: is there a way to have a link with an onclick clause that goes to a different page and runs a function on that page? For example: I am on index.html where there is a link that looks like this: <a href="about.html" onclick="javascript:runme()">About</a> If you click the link it takes you to the about.html page and runs the function runme() which is scripted on that page. Is this possible? You can always invoke javascript's function from anchor tag: <a href="javascript: func();">Cilck me!</a> In your script, put this: function func() { // call the runme function. runme(); // now redirect the page. window.location = "about.html"; } Quote Link to comment Share on other sites More sharing options...
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.