I have several thumbnails on my website. When I click on them I get a larger jpg in it's own html file. I would like these jpg's to open to their actual size only. I have tried using javascript but can't get it to work. Go to http://www.geocities.com/eyeondesign2001 and click on photoshop to see what I mean. Thanks.
But it doesn't work out how big the picture is, it depends on teh code on the button/keyframe
Code:
STUFF TO PUT IN THE HEAD TAGS OF YOUR HTML :
<script language="JAVASCRIPT" type="TEXT/JAVASCRIPT">
<!--
if(screen){
topPos=0
leftPos=0
}
function getPage(thePage,wt,ht){
leftPos= (screen.width-wt)/2
topPos = (screen.height-ht)/2
newWin1 = window.open(thePage,'aWin','toolbars=no, resizeable=no,scrollbars=no,left='+leftPos+',top='+topPos+',width='+wt+',height='+ht)
}
// -->
</script>
ACTION TO PUT ON YOUR BUTTON/IN YOUR KEYFRAME IN FLASH:
on (release) {
getURL ("javascript:getPage('http://www.yoursite.co.uk/yourpicture.jpg',300,300)");
}
this should do the trick, change the 300,300 to teh size of you photograph and the yoursite.co.uk bit to your site obviously, should work for a relative path eg just yourpic.jpg.
get back to me if you are having problems with it.
on (release) {
getURL ("javascript:window.open('http://www.geocities.com/eyeondesign2001/webad.jpg','Webad','width=375,height=400,top=0,left=0,toolbar=no,scrollbars=no,resizable=no,menubar=no,status=no,directories=no,location=no');void(0);");})
This code works with a button directly in Flash, nothing else. good luck!
gparis
Make your button action as below:
On (Release)
Get URL ("javascript:launchwin('http://www.url.com', 'newwindow', 'height=150,width=300')")")
End On
You have to have this code in your HTML page for the javascript to work:
<!--
Popup Window
<SCRIPT LANGUAGE="JavaScript"> var javascript_version = 1.0; </SCRIPT>
<SCRIPT LANGUAGE="JavaScript1.1"> javascript_version = 1.1; </SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
var newwin;
function launchwin(winurl,winname,winfeatures)
{
//This launches a new window and then
//focuses it if window.focus() is supported.
newwin = window.open(winurl,winname,winfeatures);
if(javascript_version> 1.0)
{
//delay a bit here because IE4 encounters errors
//when trying to focus a recently opened window
setTimeout('newwin.focus();',250);
}
}
</SCRIPT>
The quick and easy way (or import this to dreamweaver):::::
Publish your movie with HTML as well as SWF. Open your HTML and right click view source. Add this Code between the <Head> and </Head> tags and save as Whatever.html. Now your button should work.
hi Flashtrack,
your AS is Flash4. in Flash5 it should be:
on (release) {
getURL ("javascript:launchwin('http://www.url.com', 'newwindow', 'height=150,width=300')");}
Thanks everyone for your help, I appreaciate the help. However I still can't do it. I've tried each and every code that you posted but I still can't make it work. I am new to this so maybe I'm doing something wrong. Can someone please go and look at my website, click on photoshop and then click on my first science logo. Since I implimented the javascript I only get a blank page in this one and the webad one also. I will keep trying though, thanks.
my mistake sorry. i had an extra ')' at the end of the code. erase it and it will work now. like in:
on (release){getURL ("javascript:window.open('http://www.geocities.com/eyeondesign2001/webad.jpg','Webad','width=375,height=400,top=0,lef t=0,toolbar=no,scrollbars=no,resizable=no,menubar= no,status=no,directories=no,location=no');void(0); ");}
gparis
I can't seem to write in exactly what you have written. My code looks like this - getURL ("javascript:window.open('http://www.geocities.com/eyeondesign2001/webad.jpg','Webad','width=375,height=400,top=0,lef t=0,toolbar=no,scrollbars=no,resizable=no,menubar= no,status=no,directories=no,location=no');void(0); \");}\r\n");
Yes, I understand exactly. One more question though: If you go to my website now the webad and science logo are working but you can see a white rim around the picture. It's not there in photoshop. Any reason for this that you know of? I would like to remove it if possible, but if not it's ok. I'm just glad I finally got the windows the way I wanted them...thanks to you. Thanks for all your help.
maybe the white rim is a trace of the background (which must be white #FFFFFF) of the html page which holds the jpg. check both dimensions of jpg and pop up. you could go minus one pixel for your pop up height and width, maybe.
gparis
actually i went and check your pop up. in the html that holds the jpgs you should add these in the body tags:<BODY bgcolor="#FFFFFF" MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" BOTTOMMARGIN="0">
hope this helps
gparis