/    Sign up×
Community /Pin to ProfileBookmark

javascript popup from image

Hi,
I have been using the attached script along with a flash file to open a new window. I want to adapt the script to open the flash file from an image, i.e. when the user clicks on the image the popup window opens with my flash file.

Can anyone tell me what to put in this code in order to do this please?

<SCRIPT LANGUAGE=’JavaScript’>

function popUp(){
window.open(‘../Games/Link.swf’,”,’scrollbars=no,height=550,width=720,left=0,top=0′);
}

</script>

Thanks in advance

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@steelersfan88Apr 11.2004 — keep that in the head section, and make the image appear like:&lt;img src="..." alt="..." onclick="popUp()"&gt;
Copy linkTweet thisAlerts:
@ezryderauthorApr 12.2004 — Thanks for the reply.

I have tried this but it doesn't seem to work, now I have the following script in the header:

[CODE]
<SCRIPT LANGUAGE='JavaScript'>

function popUp(){
window.open('../Games/Angles.swf','','scrollbars=no,height=550,width=720,left=0
,top=0');
}

</script>
[/CODE]


and this in the body:

[CODE]
<img src="Flash%20buttons/Movie3.gif" alt = "Alternate text" width="200" height="135"onclick="popUp()">
[/CODE]



I know next to nothing about javascript and html but I looked up what the alt parameter was and I read this is alternative text in case the image doesn't display.

I'm also wondering if I want to display two images on the page given that the link is defined in the javascript section how would I do this.

Apologies for the simple questions - is there a tutorial which covers this? I've looked but I can't find any.

Thanks again.
Copy linkTweet thisAlerts:
@steelersfan88Apr 12.2004 — This should work:[code=php]<script type="text/javascript">

function popUp() {
// left and top are supposedly IE only
var newWin = window.open('../Games/Angles.swf','_blank','height=550,width=720,left=0,top=0');
// this will create an error if game not on same server as opener
newWin.moveTo(0,0)
}

</script>

<img src="Flash%20buttons/Movie3.gif" alt="Alternate text" width="200" height="135" onclick="popUp()">
<!-- Content -->
<img src="Flash%20buttons/anotherPicture.gif" alt="Alternate text" width="200" height="135" onclick="popUp()">[/code]
That has two pictures, there are many javascript tutorials, use the search feature on these forum. Here are 2 fro ma good friend:[list=1]
  • [*]http://www.howtocreate.co.uk/tutorials/index.php?tut=0&part=0&TOshow=allshow

  • [*]http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/ix.html

    [/list=1]
  • Copy linkTweet thisAlerts:
    @ezryderauthorApr 12.2004 — Thanks again that worked for me.

    However, I didn't quite phrase what I said correctly, what I meant was how would I have two different links on the same page from two different pictures given that the link is specified in the javscript already?
    Copy linkTweet thisAlerts:
    @ezryderauthorApr 12.2004 — OK I think I figured it out ... just call the javascript function popup2 and refer to that in the link. Is this the best way?
    Copy linkTweet thisAlerts:
    @steelersfan88Apr 12.2004 — If I understand you correctly, you would have to send the URL as an argument to the url parameter, as such:[code=php]<script type="text/javascript">

    function popUp(url) {

    // left and top are supposedly IE only
    var newWin = window.open(url,'_blank','height=550,width=720,left=0,top=0')
    ;

    // this will create an error if game not on same server as opener
    newWin.moveTo(0,0)
    }

    </script>

    <img src="Flash%20buttons/Movie3.gif" alt="Alternate text" width="200" height="135" onclick="popUp('../Games/Angles.swf')">
    <!-- Content -->
    <img src="Flash%20buttons/anotherPicture.gif" alt="Alternate text" width="200" height="135" onclick="popUp('../Games/NewGame.swf')">[/code]
    Send the source of the game in ('Source') ?
    ×

    Success!

    Help @ezryder spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.16,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...