Staredit Network > Forums > Technology & Computers > Topic: onClick Popup window
onClick Popup window
Aug 16 2009, 2:05 am
By: Riney  

Aug 16 2009, 2:05 am Riney Post #1

Thigh high affectionado

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.

Aug 16 2009, 2:37 am Jack Post #2

>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."

Aug 16 2009, 6:08 am Riney Post #3

Thigh high affectionado

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.

Aug 16 2009, 7:12 am Corbo Post #4

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:
Code
<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

Aug 16 2009, 9:48 am Jack Post #5

>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."

Aug 16 2009, 2:03 pm Syphon Post #6



target="_blank" is deprecated.

Use <a href="" onClick="window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n')">Linky</a>



None.

Aug 16 2009, 5:29 pm Riney Post #7

Thigh high affectionado

Quote from Syphon
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.

Aug 16 2009, 7:10 pm ShadowFlare Post #8



Quote from Syphon
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.

Aug 18 2009, 6:08 am Kyrax Post #9



Quote from ShadowFlare
Quote from Syphon
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.

Aug 18 2009, 12:56 pm Syphon Post #10



Quote from Kyrax
Quote from ShadowFlare
Quote from Syphon
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.

Aug 18 2009, 4:32 pm Doodle77 Post #11



Quote from Syphon
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
Code
<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
Code
<a href="URL YOU WANT" onClick="window.open('URL YOU WANT','NAME OF WINDOW','width=n,height=n'); return false;">Linky</a>




None.

Aug 18 2009, 8:47 pm Kyrax Post #12



Quote from Syphon
Quote from Kyrax
Quote from ShadowFlare
Quote from Syphon
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 :wtfage:



None.

Aug 18 2009, 9:00 pm ShadowFlare Post #13



PHP code runs on the server, not the web browser. It cannot have a direct effect on the web browser.



None.

Aug 18 2009, 9:15 pm Kyrax Post #14



Quote from ShadowFlare
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... :wtfage:



None.

Aug 19 2009, 4:06 am Syphon Post #15



Quote from Doodle77
Quote from Syphon
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
Code
<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
Code
<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.

Quote from Kyrax
Quote from ShadowFlare
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... :wtfage:

Why would you do that instead of, say, just making it a link.



None.

Aug 19 2009, 4:35 am ShadowFlare Post #16



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)

Code
<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.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[04:59 am]
zsnakezz -- >:)
[04:59 am]
zsnakezz -- :)
[04:58 am]
zsnakezz -- somebody gets it
[04:58 am]
zsnakezz -- and its not all just numbers in my file screen
[04:57 am]
zsnakezz -- thank you for your comment though, good to know some people out there tried my map out
[04:57 am]
zsnakezz -- just kidding
[04:57 am]
zsnakezz -- ultra you have any thought or notes on undead invasion?
[2024-5-31. : 2:36 pm]
Wing Zero -- Bop em
[2024-5-31. : 2:36 pm]
Wing Zero -- Mods
[2024-5-29. : 9:40 pm]
Ultraviolet -- :wob:
Please log in to shout.


Members Online: Roy, Oh_Man