jamesx521
10-07-2006, 10:03 PM
How can I have two commands under one <a href>? It's a MP3 file link; the first one starts playing the song, but on that click I want the page they are on to link to another page too. Thanks.
|
Click to See Complete Forum and Search --> : Two commands under one href? jamesx521 10-07-2006, 10:03 PM How can I have two commands under one <a href>? It's a MP3 file link; the first one starts playing the song, but on that click I want the page they are on to link to another page too. Thanks. Neoboffin 10-08-2006, 05:45 AM You can do this by Javascript. <script language="javascript" type="text/javascript"> function letsGo(play, to) { // Your MP3 plyer stuff here. // Go to link window.location = to; } </script> Then for your links add like: <a href="javascript: letsGo('mp3_file_to_play.mp3', 'new_url.html');">Play this MP3!</a> Znupi 10-08-2006, 06:10 AM Or you could, more easily in my opinion, do something like : <a href="javascript: function1(param); function2(); function3(); etc();">Link</a> Or ... if you want it to look pretty, and not print in the user's status bar all the functions that you call, use : <a href="javascript:void(0)" onClick="function1(params); function2(); etc();">Link</a> I hope this helps... jamesx521 10-09-2006, 01:16 PM How should I include target="_blank" for their MP3 player that will open, yet target="_self" for the new page; does the code go outside the two (params), or inside? jamesx521 10-09-2006, 01:38 PM Where it says Your MP3 plyer stuff here do I put MP3 file-names? Like this: // test.mp3 Where it says Go to link window.location = to; do I put the URL on the place of to? // Go to link window.location = test.html; <script language="javascript" type="text/javascript"> function letsGo(play, to) { // Your MP3 plyer stuff here. // Go to link window.location = to; } </script> Neoboffin 10-09-2006, 02:07 PM I assumed you had Javascript knowledge. How are you trying to play these mp3 files. Through the user's media players on their desktops or through your web site? jamesx521 10-09-2006, 10:45 PM Right now what I have is: <a href="test.mp3" target="_blank"> so it opens the file in whatever their IE, Mozzila, etc. native-audio-player is. I definitely need the target="_blank" for the MP3, so that their audio-player doesn't open on the same window as the web page. And with the second href I want that page to change to another page target="_self". Neoboffin 10-10-2006, 05:29 AM Use this: <a href="my_mp3.mp3" target="blank" onClick="window.location = 'http://yahoo.com/';">Play MP3</a> jamesx521 10-10-2006, 12:08 PM I forgot that my link is in an iframe in the page, so for this part: onClick="window.location = 'http://yahoo.com/' I would need to add target="_parent" somewhere: where? Thanks. Neoboffin 10-10-2006, 12:19 PM Give your IFrame a unique ID such as: id="myFrame" Then change this: onClick="window.location = 'http://yahoo.com/';" To: onClick="document.getElementById('myFrame').src = 'http://yahoo.com/';" jamesx521 10-10-2006, 01:03 PM I followed your directions Neoboffin but it didn't work. I put ID in the iframe and used the new onClick code too. The page doesn't change at all. In the previous version: onClick="window.location = 'http://yahoo.com/';" the page did change, except it was in the iframe. Are there other solutions? Thanks. Neoboffin 10-10-2006, 01:08 PM Like this? -- It works for me. <iframe id="myFrame" width="400" height="400"></iframe> <a href="my_mp3.mp3" target="blank" onClick="document.getElementById('myFrame').src = 'http://yahoo.com/';">Play MP3</a> jamesx521 10-10-2006, 02:07 PM That's what I have, except with different names and links. My iframe is placed within <div></div>. Would that interfere anyhow? jamesx521 10-11-2006, 12:16 PM Do I still need this code in the iframe page: <script language="javascript" type="text/javascript"> function letsGo(play, to) { // Your MP3 plyer stuff here. // Go to link window.location = to; } </script> when I use the two codes below... the first, in the main page that calls the iframe: <iframe id="myFrame" width="400" height="400"></iframe> and this second, in the iframe page: <a href="my_mp3.mp3" target="blank" onClick="document.getElementById('myFrame').src = 'http://yahoo.com/';">Play MP3</a> Neoboffin 10-12-2006, 05:40 AM No you don't need that javascript code on any page. I'm not sure what your asking about the other stuff either. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |