So heres my dillema. I got a site im trying to make, but I need a onClick code to make a small 150x100 popup window appear so I can have a small music file played in it.
Well so far I have this function that Im sure works, but the onClick part im unsure about. I have a hunch its like <A HREF="Something" onClick="do my thing">Rawr</A>, but Ive yet to figure out how to do it. Either a better method or a tutorial would be greatly appreciated.
.riney on Discord.
Riney on Steam (
Steam)
@RineyCat on Twitter
Sure I didn't pop off on SCBW like I wanted to, but I won VRChat. Map maker for life.
>be faceless void >mfw I have no face
Try <FORM>
<INPUT type="button" value="Music" onClick="window.open('DMSMUSICFILE.MP3',width=150,height=100)">
</FORM>
I can't test it ATM, replace the DMSMUSIC.MP3 with your music file, or your page you already made for it. If you leave it as a music file, you probably have to remove the height and width attributes.
Red classic.
"In short, their absurdities are so extreme that it is painful even to quote them."
I was really hoping I didnt have to have a button though xD
.riney on Discord.
Riney on Steam (
Steam)
@RineyCat on Twitter
Sure I didn't pop off on SCBW like I wanted to, but I won VRChat. Map maker for life.
ALL PRAISE YOUR SUPREME LORD CORBO
I can't see why that shouldn't work with a link.
And anyway, why don't you do:
<a href="thepagethatcontainsthemusic" target="_blank''>rawr</a>
and make the other page that opens a fixed size, rather than trying to fix the size from a weird onClick thingy.
You can use this on the other page that's supposed to open:
<head>
<script LANGUAGE="javascript">
function Resize(w,h){
window.resizeTo(w,h);
}
</script>
</head>
<body onload="javascript:void window.Resize(200,100); ">
<!-- Music console or whatever here -->
HAI GAIS
</body>
That might now work if the user has the browser to open all new windows in a new tab.
Post has been edited 2 time(s), last time on Aug 16 2009, 7:21 am by Corbo.
fuck you all
>be faceless void >mfw I have no face
I think he wants a little floating box though. And DM it doesn't have to be a button.
Red classic.
"In short, their absurdities are so extreme that it is painful even to quote them."
target="_blank" is deprecated.
Use <a href="" onClick="window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n')">Linky</a>
None.
target="_blank" is deprecated.
Use <a href="" onClick="window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n')">Linky</a>
Worked perfectly. Thanks bunches.
.riney on Discord.
Riney on Steam (
Steam)
@RineyCat on Twitter
Sure I didn't pop off on SCBW like I wanted to, but I won VRChat. Map maker for life.
target="_blank" is deprecated.
Use <a href="" onClick="window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n')">Linky</a>
It is good to have as a fall-back for when Javascript is disabled or for a web browser that doesn't support Javascript, though.
None.
target="_blank" is deprecated.
Use <a href="" onClick="window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n')">Linky</a>
It is good to have as a fall-back for when Javascript is disabled or for a web browser that doesn't support Javascript, though.
Excellent point! PHP is a nice backup
None.
target="_blank" is deprecated.
Use <a href="" onClick="window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n')">Linky</a>
It is good to have as a fall-back for when Javascript is disabled or for a web browser that doesn't support Javascript, though.
Excellent point! PHP is a nice backup
You couldn't make an onclick popup window with PHP. PHP is serverside, and you'd still need some client-side scripting like AJAX, that sends a request to server that modifies a table depending on which popup you want opened, and opening the popup when the AJAX call is completed... If you want to really overcomplicated things.
None.
target="_blank" is deprecated.
Use <a href="" onClick="window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n')">Linky</a>
It's a better idea to use
<a href="javascript:window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n');">Linky</a>
Or if you were to follow Shadowflare's suggestion and have a fallback, you'd do
<a href="URL YOU WANT" onClick="window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n'); return false;">Linky</a>
None.
target="_blank" is deprecated.
Use <a href="" onClick="window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n')">Linky</a>
It is good to have as a fall-back for when Javascript is disabled or for a web browser that doesn't support Javascript, though.
Excellent point! PHP is a nice backup
You couldn't make an onclick popup window with PHP. PHP is serverside, and you'd still need some client-side scripting like AJAX, that sends a request to server that modifies a table depending on which popup you want opened, and opening the popup when the AJAX call is completed... If you want to really overcomplicated things.
Make a PHP file that loads on the click of a button that is inside a form. Sure, it would open up in the same window and wouldn't be just like the Javascript way, but we're talking about creating a fail-safe for Javascript if its not enabled......At least I thought
None.
PHP code runs on the server, not the web browser. It cannot have a direct effect on the web browser.
None.
PHP code runs on the server, not the web browser. It cannot have a direct effect on the web browser.
I know this...But you could make a script that brings up XHTML and you could make a webpage from inside the PHP code and activate the code (as a fail-safe) to produce the XHTML page, and have the picture on it...
None.
target="_blank" is deprecated.
Use <a href="" onClick="window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n')">Linky</a>
It's a better idea to use
<a href="javascript:window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n');">Linky</a>
Or if you were to follow Shadowflare's suggestion and have a fallback, you'd do
<a href="URL YOU WANT" onClick="window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n'); return false;">Linky</a>
When I tried using the javascript: protocol to make a popup in Fx 3.5, the page unloaded before the popup popped up, which is why I went for onClick.
PHP code runs on the server, not the web browser. It cannot have a direct effect on the web browser.
I know this...But you could make a script that brings up XHTML and you could make a webpage from inside the PHP code and activate the code (as a fail-safe) to produce the XHTML page, and have the picture on it...
Why would you do that instead of, say, just making it a link.
None.
So basically, if you want the new window a certain size, but still want the link to open a new window (or at least tab) if the user has Javascript disabled, use something like this: (taking Doodle77's example)
<a href="URL YOU WANT" onClick="window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n'); return false;" target="_blank">Linky</a>
By the way, the return false at the end of the handler is so that the browser doesn't also use the href part of the link.
None.