-
Open new window with Javascript
I have a thumbnail that when clicked it opens an image or site in a new window with a specific size. Previously the folllowing script worked just fine. All of a sudden it will only open within the same window, not a new one, and nothing has been changed. The odd thing is that it does work fine when in Flash and testing it in a browser. It doesn't work after I upload it.
I have been using this script:
on (release) {
getURL ("javascript:NewWindow=window.open('pic7.html','ne wWin','width=550,height=400,left=300,top=300,toolb ar=No,location=No,scrollbars=No,status=No,resizabl e=No,fullscreen=No');NewWindow.focus();void(0);");
}
I have read in another post that something needs to be added into the head of the html that the swf is imbedded in. I tried this script in the head:
<SCRIPT LANGUAGE="javascript">
function popup(url,name,features){
var newWin = window.open(url,name,features);
}
</script>
But it still doesn't work.
Any suggestions?
-
Senior Member
-
I tried using the code you had in the head of your html doc.
function NewWindow(mypage, myname, w, h, scroll) {
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl +',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus();
}
(side note: I had to eliminate the SCRIPT LANGUAGE="JavaScript" part in this post b/c it otherwise would not appear in the post. It is, however, properly used in my HTML doc.)
I used the following code on the button in my flash doc:
on (release) {
getURL ("javascript:NewWindow=window.open('pic5.html','ne wWin','width=550,height=400,left=300,top=300,toolb ar=No,location=No,scrollbars=No,status=No,resizabl e=No,fullscreen=No');NewWindow.focus();void(0);");
}
It works great when testing in a browser, as usual, but still won't work when I upload it. It still opens the file in the same window instead of a new one.
What could I be doing wrong if it worked fine before?
-
-
I was just thinking that I should add that. http://www.bigmac223.addr.com - enter and navigate to the photos section and click any photo to see what is happening. Attaching my flash file would just be confusing. It is very detailed. If need be I can make a new project really quick with just that code.
-
Have you tried using the full url rather than just 'pic7.html' as an example.
And is your photos section a seperate external movie, or is it within your main movie?
-
It is not in a seperate external movie, it is in a movie within my main movie.
I just tried using the full url and it does the same thing. I have also tried having it call up a jpeg instead of a url, same thing happens. I am starting to thing my file got corrupt or something.
-
Try this on one of those thumbnails to see if the same thing happens?
Code:
on (release) {
getURL ("javascript:window.open('http://www.google.com/','','width=400,height=300,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No');NewWindow.focus();void(0);");
}
You know that you should have no space between java & script in the above, and no linebreaks either, right?
This must be one continuous line.
-
Yes I do know to have no spaces and I didn't. I guess it was the NewWindow=window.open I had in there that messed it up, maybe. Whatever the reason was, it now works!! Thank you so much for all of your help. I really appreciate you taking the time.
-
Ummmmmmh! It does work for me with both scripts, so it must of been something else.
-
Odd! I have been playing around with it more. The new script works on and off. The first time no, the second time yes. I am just glad to get it working at all.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|