views:

234

answers:

1

hi,

again trying to do music in a homepage.

The music should play on load ...

this is how i try to do it.

  1. setting up a "window.open" like

    function Audio() { MyWindow = window.open('mp3/mp3player.html', 'mp3player', "width=130,height=120,left=0,left=100,top=100,location=no"); MyWindow.focus(); }

and an

Now the music plays in the Popup .. so far so good!

  1. on everypage there is a speaker symbol that should open the pop-up again to be able to stop the music.

e.g. . also javascript seems to be needed to be implemented in all pages otherwise the set focus doesnt seem to work at all.

the problem is that not only the focus is set but also the page seems is loaded. so the music starts at the beginning :-(

what am i doing wrong? or is there no solution for this?

A: 

First, please please please don't have music that auto-plays when I visit your web page! OK, now that I've got that off my chest. :-) Assuming your going to do this...

The problem is, your music is restarting because you're reloading the page each time. You need a way to get a reference to the window if it already exists when you navigate to a new page in the main window (not the popup window). That's easier said than done, you've very much in browser-specific land here, and doing something that really smells like an XSS attack. I'm not saying that your usage is XSS, just that it will appear to be XSS to the browser so it's not likely to be allowed. Having said that, I have seen this done, but it's ugly... Make your site a frames-site (remember those) and then have two frames in that site, one that your user sees, and one that holds a reference to the popup window. This way, you navigate in your frame, and the other frame is free to keep a reference to the popup. But I refer you to my initial request. :-)

WaldenL