|
Author |
Topic: javaScript pop-ups (Read 420 times) |
|
leth
|
javaScript pop-ups
« on: Jul 20th, 2004, 4:41pm » |
|
Hi I posted about 3 weeks ago and have been away on holliday, so I try again. I had a question about javaScript pop ups, how to make them. I got an answer from Toxi, thank you: It goes: you can't open browser popups directly with the processing syntax, though you can call a javascript from your sketch to do exactly that (just like you'd do it from flash): Code: void mouseReleased() { link("javascript:window.open('blah.htm','blah','width=400,height=400,too lbar=false,status=false');"); } .... But I still can't make it work. I am not so skilled in either processing nor javaScript yet. I am not sure, what to write in the html document, and where to write it. Hope someone can help me, thanks, Leth
|
|
|
|
narain
|
Re: javaScript pop-ups
« Reply #1 on: Jul 21st, 2004, 5:48am » |
|
link() will only work when viewing the sketch in a web browser. So you can't test it in Processing; you'll have to export it. You don't have to change anything in the HTML document. Whenever link() gets called in the sketch, the pop-up will be opened. For more info about window.open's syntax, see http://javascript.about.com/library/weekly/aa031203a.htm
|
|
|
|
leth
|
Re: javaScript pop-ups
« Reply #2 on: Jul 21st, 2004, 11:09am » |
|
Thank you But it still does not work. I simply just use the code Toxi gave me and put it as the only thing in processing. Then I export. But from within Internet Explorer it does not work... Did I miss something??
|
|
|
|
narain
|
Re: javaScript pop-ups
« Reply #3 on: Jul 21st, 2004, 12:39pm » |
|
It's working at my end... Toxi's example calls link() in the mouseReleased() function, which gets run when the mouse is clicked over the sketch. If you want it to pop up as soon as the sketch is opened, put the link() statement in the setup() method instead.
|
|
|
|
leth
|
Re: javaScript pop-ups
« Reply #4 on: Jul 21st, 2004, 1:54pm » |
|
I have tested on another computer now, and it works, thanks, but when the pop-up has been opened, the window with the processing applet changes and displays: [object] and in the titel: javascript:window.open...etc I have tried different things: spelling javascript: JavaScript opening a new window throuhg p5: "_new" and more but non of it seams to work... Do you know if the p5 to javascript is stabil? or is it just something obvious, that I just don't know, because I am not so much into it? Thanks, Lene
|
|
|
|
narain
|
Re: javaScript pop-ups
« Reply #5 on: Jul 22nd, 2004, 6:15am » |
|
Oh yes... That's a pretty common Javascript issue. Everybody runs into that one at least once The browser is just trying to follow the link like a normal http:// address. Since it happens to start with javascript:, it also executes the JS code, but after that it also tries to do what it normally does with links: set its Address bar to that address, and open it like a web page. Edit: Oops, I clicked Post by mistake. I haven't really got a solution for this right now, actually. I just knew why it was happening. Edit 2: Ah, I got it to work. Apparently, if you wrap window.open() inside another Javascript function call, it works fine... I'm not sure why, but it may be that window.open returns some value while the user-defined function doesn't. Anyway, here's what I put together, tested in Firefox and IE6: javascript:function winopen(url) {window.open(url,'blah','width=400,height=400,toolbar=false,status=false ');}; winopen('blah blah');
|
« Last Edit: Jul 22nd, 2004, 6:24am by narain » |
|
|
|
|
leth
|
Re: javaScript pop-ups
« Reply #6 on: Jul 22nd, 2004, 11:49am » |
|
Perfect This actually works on both my computers. Thank you so much, Narain. Really great!!!
|
|
|
|
|