Mateusz Viste a écrit :
>
The problem is the following:
On my local PC, the script needs to be called like that:
playmedia('goodies/antarcti/antarcti.mid')
Just like it would be in the root directory (in fact, it is not, but at the
begin I assumed that JavaScript is acting like that).
Not at all !
That means folder 'goodies' is in same folder than the file that opens
the popup. (you certainly have a copy of 'goodies' or an alias of it in
'htm_roms' on your PC, or you did get one and Fx uses its cache)
the file with the script could be here : /nes/htm_roms/
when midi file is here : /nes/htm_roms/goodies/antarcti/
The JS follows relative links from the page where it is declared
(or linked), it could not happen any error about the hrefs it they are
set like in the page in html code.
When I put the same script/website on my web server, my browser (the same I
used locally - Firefox 3.0.1) is acting like the current directory wasn't
the same anymore:
GET /mateusz/nes/htm_roms/goodies/advisln3/advtitle.mid HTTP/1.1
That url is correct if the html file in 'htm_roms' calls :
'goodies/antarcti/antarcti.mid'
Which is not correct, as the root of the website is /mateusz/nes ,
more probably the exact root is : /mateusz/ (href="/")
/nes/ is a kind of sub-site (its relative root is : href="/nes/" )
and the
media file is in /mateusz/nes/goodies/advisln3/advtitle.mid :(
Right ! :-)
And that is the point which I definetely doesn't understand - why my browser
is changing the reference path when used locally...
No it doesn't, it can't !
delete your folder 'goodies' in 'htm_roms' on your PC
(or move it back to 'nes')
don't know where I have to search - is it a Firefox bug, something
JavaScript-specific, anything else...? But I guess it's offtopic for this
group anyway :-)
Well, I see here, in your page :
<http://viste.homeip.net/mateusz/nes/htm_roms/advisln3.htm>
with the code (correct as 'htm_roms' is with 'goodies' in 'nes'):
<a href="../goodies/advisln3/advtitle.mid" target="_blank">
Adventure Island 3 title music theme</a>
In the head of this page you could have :
<script type="text/javascript" src="../js/sound.js"></script>
Then you save in folder /nes/js/
the file 'sound.js' containing exactly :
function pop(what) {
if(typeof nw = 'undefined' || nw.closed)
nw = window.open('','','width=300,height=60,resizable=1 ');
nw.location = what.href; // to avoid any mistake
nw.focus();
return false;
}
Then your link becomes :
<a href="../goodies/advisln3/advtitle.mid" target="_blank"
onclick="return pop(this);" title="To listen the musical theme">
Adventure Island 3 title music theme</a>
=================
You can also have the script in your menu's page
<http://viste.homeip.net/mateusz/nes/html/index.htm>
<head>
<title>NES games repository</title>
<meta
(...)
<script type="text/javascript" src="../js/sound.js"></script>
</head>
The opened pages in right frame no more have JS's script
and their links to play sound are this way :
<a href="../goodies/advisln3/advtitle.mid" target="_blank"
onclick="return parent.index.pop(this);"
title="To listen the musical theme">
Adventure Island 3 title music theme</a>
=================
You can also have the script in your main page :
<http://viste.homeip.net/mateusz/nes/index.htm>
<script type="text/javascript" src="js/sound.js"></script>
</head>
Right pages will be without JS and with links this kind :
<a href="../goodies/advisln3/advtitle.mid" target="_blank"
onclick="return parent.pop(this);"
title="To listen the musical theme">
Adventure Island 3 title music theme</a>
--
sm