/    Sign up×
Community /Pin to ProfileBookmark

Make picture permanently visible when clicking link

Hi folks,
I have a question regarding a script.
I´ve made a page with a number of buttons. When you move the cursor over each one of them, a picture shows in another part of the page which contains info about the buttons subject. I would like that picture to be permanently visible when you´ve clicked on the button instead of disappearing again. I´ve tried experimenting with the “OnClick” & “TurnOn” commando but I can´t get it to work.

Here´s the code attached to the button:

[CODE]<a href=”javascript:pop00()”
onMouseOver=”turnDown(‘image101’, ‘popup1.src’);”
onMouseOut=”turnOff(‘image1’);turnOff(‘image101’);”
onMouseDown=”turnDown(‘image101’, ‘popup1.src’);”
onClick=”turnOn(‘image101’, ‘popup1.src’);”>
<img name=”image1″ src=”images/greendot.gif” border=”0″ width=”26″ height=”26″ align=”middle”></a>[/CODE]

And here´s the main script within the head marks. I wonder if I should change anything here too?

[CODE]<script>
<!–
if (document.images) {

image101off = new Image();
image101off.src = “popup1_blank.gif”;
image102off = new Image();
image102off.src = “popup2_blank.gif”;
image103off = new Image();
image103off.src = “popup3_blank.gif”;

image1on = new Image();
image1on.src = “bild1_over.gif”;

image1off = new Image();
image1off.src = “bild1.gif”;

image101popup1 = new Image();
image101popup1.src = “popup1.jpg”;

image2on = new Image();
image2on.src = “bild2_over.gif”;

image2off = new Image();
image2off.src = “bild2.gif”;

image102popup2 = new Image();
image102popup2.src = “popup2.jpg”;

image3on = new Image();
image3on.src = “bild3_over.gif”;

image3off = new Image();
image3off.src = “bild3.gif”;

image103popup3 = new Image();
image103popup3.src = “popup3.jpg”;

}
function turnOn(imageName)
{
if (document.images) {
document[imageName].src = eval(imageName + “on.src”);
}
}

function turnOff(imageName) {
if (document.images)
{
document[imageName].src = eval(imageName + “off.src”);
}

}
function turnDown(imageName, imageEnd) {
if (document.images)
{
document[imageName].src = eval(imageName + imageEnd);
}
}
// –>
</script>[/CODE]

I´m tearing my imagined hair about this. Would be a great relief if anyone had an answer to this.

Peace/Ilja

to post a comment
JavaScript

20 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterMay 18.2005 — &lt;img [color=red]name[/color]="image1" src="images/greendot.gif" border="0" width="26" height="26" align="middle"&gt;
replace the red area with: [color=green]id[/color]

And use the following three functions in place of your own:
<i>
</i>function turnOn(imageName){
document.getElementById(imageName).src = window[imageName + "on"].src
}

function turnOff(imageName) {
document.getElementById(imageName).src = window[imageName + "off"].src
}

function turnDown(imageName, imageEnd) {
document.getElementById(imageName).src = window[imageName + imageEnd].src
}
Copy linkTweet thisAlerts:
@JamesOneauthorMay 18.2005 — ..for your quick reply! I didn´t get it to work though. All that happened was that the buttons were clickable but neither the picture showed nor stayed when you clicked the button.
Copy linkTweet thisAlerts:
@JamesOneauthorMay 18.2005 — Check the page at [URL=http://www.ilja.se/magasin3/magasin3.htm]http://www.ilja.se/magasin3/magasin3.htm[/URL],

I´m still not sure to do.
Copy linkTweet thisAlerts:
@UltimaterMay 18.2005 — NO.......

Each ONCLICK should use the [i]exact[/i] code word for word as the matching ONMOUSEOUT in each seperate case. My code was an example designated to just one of those circles.

Thus, you'd change:
<i>
</i>&lt;a href="javascript:pop00()"
onMouseOver="turnDown('image1011', 'popup11.src');"
onMouseOut="turnOff('image11');turnOff('image1011');"
onMouseDown="turnDown('image1011', 'popup11.src');"
onClick="turnDown('image1011', 'popup11.src');"&gt;


into:
<i>
</i>&lt;a href="javascript:pop00()"
onMouseOver="turnDown('image1011', 'popup11.src');"
onMouseOut="turnOff('image11');turnOff('image1011');"
onMouseDown="turnDown('image1011', 'popup11.src');"
onClick=[color=royalblue]turnOff('image11');turnOff('image1011');"[/color]
Copy linkTweet thisAlerts:
@JamesOneauthorMay 20.2005 — I´m getting a bit confused about your explanations, since I have another thread wit a differerent problem about the same page, both of ur answers has to do with the OnClick-string, am I mistaking myself in some way cause I can´t make it work?
Copy linkTweet thisAlerts:
@UltimaterMay 20.2005 — I'll even go through each of the changes that need to be done for ya.

Here's your first [b]A[/b]-TAG that needs adjustment:
[code=html]
<a href="javascript:pop00()"
onMouseOver="turnDown('image101', 'popup1.src');"
onMouseOut="turnOff('image1');turnOff('image101');"
onMouseDown="turnDown('image101', 'popup1.src');"
onClick="turnDown('image101', 'popup1.src');"
onMouseUp="turnDown('image101', 'popup1.src');">
[/code]

Change all of that into:
<i>
</i>&lt;a href="javascript:pop00()"
onMouseOver="turnDown('image101', 'popup1.src');"
onMouseOut="turnOff('image1');turnOff('image101');"
onMouseDown="turnDown('image101', 'popup1.src');"
onClick=[color=royalblue]"turnOff('image1');turnOff('image101');"[/color]
onMouseUp=[color=royalblue]"turnOff('image1');turnOff('image101');"&gt;[/color]







Your second [b]A[/b]-TAG is Ok ?

Your third [b]A[/b]-TAG is also OK ?

Your forth [b]A[/b]-TAG needs adjustment.
[code=html]
<a href="javascript:pop00()"
onMouseOver="turnDown('image104', 'popup4.src');"
onMouseOut="turnOff('image4');turnOff('image104');"
onMouseDown="turnDown('image104', 'popup4.src');"
onClick="turnDown('image104', 'popup4.src');">
[/code]

change all of that into:
<i>
</i>&lt;a href="javascript:pop00()"
onMouseOver="turnDown('image104', 'popup4.src');"
onMouseOut="turnOff('image4');turnOff('image104');"
onMouseDown=[color=royalblue]"turnOff('image4');turnOff('image104');"[/color]
onClick=[color=royalblue]"turnOff('image4');turnOff('image104');"[/color]&gt;


I'm sure you can see the pattern. The pattern is that the ONCLICK event is an exact copy of everything that happens when an ONMOUSEOUT event occurs.

The same goes for the ONMOUSEDOWN event because you don't need both an ONMOUSEDOWN event and a ONCLICK event.

Thus, all three of them should be doing the same thing.
Copy linkTweet thisAlerts:
@JamesOneauthorMay 20.2005 — Thank you very much for your answers! I´m still feeling a bit dumb since I still can´t make it work, a javascript noob that I am.

I saw that you answered in my other thread too, about the animation.

Take a look again at [URL=http://www.ilja.se/magasin3/magasin3.htm]http://www.ilja.se/magasin3/magasin3.htm[/URL]

I would like the words that show up on the right side of the dots to stay there once you´ve clicked one of the dots.

At the same time I want the animations to continue working, and not to stop blinking just because the pop-up came up.

I don´t know what to do anymore...Have a deadline tomorrow and took a bit too much water over my head so I´m close to a nervous breakdown.

Could you help me to rewrite the code in a proper way since it seems to get wrong whereever I touch it at the moment..
Copy linkTweet thisAlerts:
@UltimaterMay 20.2005 — I'll do it if you sign my guestbook and add a chapter to my interactive story afterwards ?
Copy linkTweet thisAlerts:
@JamesOneauthorMay 20.2005 — Of course ?

Thank you!!!
Copy linkTweet thisAlerts:
@UltimaterMay 20.2005 — Ok, but I won't be able to work on it for another hour but It shouldn't take me more than 10 minutes to touch it up. Come back in an hour or so.
Copy linkTweet thisAlerts:
@UltimaterMay 20.2005 — The problem is that the HREF of the A tag makes the images stop because the script thinks it's going to a new page. Not even javascript: works but using a hash(#) does.

<A

[color=royalblue]onmouseup="pop00()"[/color]

onmousedown="turnDown('image101', 'popup1.src');"

onmouseover="turnDown('image101', 'popup1.src');"

onclick="turnOff('image1');turnOff('image101');"

onmouseout="turnOff('image1');turnOff('image101');"

[color=royalblue]href="#"[/color]>

Transfer the HREF equals string to the ONMOUSEUP event.

I'll do all this for you and post it as an attachment.
Copy linkTweet thisAlerts:
@UltimaterMay 20.2005 — One of the wierdiest errors that I have ever seen in my life is that you need to omit the tag in your code that reads:
&lt;META content="" name=""&gt;
Even though that it is a blank tag, it's been causing alot of problems.

That one is for the records ?
Copy linkTweet thisAlerts:
@UltimaterMay 20.2005 — This is your finished code:

(attachment)

Just simply rename the file to magasin3.htm and upload the file to your server in place of your http://www.ilja.se/magasin3/magasin3.htm file.

?

note: you might wanna back-up the file from your server just in case I missed something.

[upl-file uuid=92434de1-d692-41db-8e2e-2161cb3db587 size=43kB]Magasin 3 Projekt.htm.txt[/upl-file]
Copy linkTweet thisAlerts:
@JamesOneauthorMay 20.2005 — ...so much!!! Now the animations work fine!

Check at [URL=http://www.ilja.se/magasin3/magasin3projekt.htm]http://www.ilja.se/magasin3/magasin3projekt.htm[/URL]

But the mouseover thing with the pics that then stay permanent doesn´t work? Or am I doing something strange?


Peace
Copy linkTweet thisAlerts:
@UltimaterMay 20.2005 — So the URL of your flashing green circle is http://www.ilja.se/magasin3/images/greendotani.gif

Did you want the image to stop flashing when you put your mouse over it?

So, if my mouse is elsewhere, then, the image will be a flashing green "dot", but, if my mouse is over it, then it will be a non-animated green dot.

But what's the URL of the image that you wish to replace it with when you put your mouse over it?
Copy linkTweet thisAlerts:
@JamesOneauthorMay 22.2005 — No, the animations is fine. They are supposed to blink at all time.

But now I´m having a problem with all the pop up windows connected to the animated dots. All the pathways are right but when I click on one of the

dots/buttons I get a "code-problem-message" from Explorer.

Check at [URL=http://www.ilja.se/magasin3/magasin3projekt.htm]http://www.ilja.se/magasin3/magasin3projekt.htm[/URL]

The page has a pathway to a .js file that´s named "popups.js" inside the head-tags:

[CODE]<script language="javascript" src="popups.js"></script>[/CODE]

All the links are as follows:

[CODE]<A onmouseover="turnDown('image103', 'popup3.src');"
onmouseup="pop00()"
onclick="turnOn('image3');turnOn('image103');this.onmouseover= 'popup3.src'"
onmouseout="turnOff('image3');turnOff('image103');"
href="#"><IMG height=26
src="images/lightbluedot.gif" width=26
border=0 name=image3></A>[/CODE]



How should I do to make this work?

And again, a big thanks!
Copy linkTweet thisAlerts:
@UltimaterMay 22.2005 — Your pop00 function is corrupted.
<i>
</i>onclick=window.open('nyruta.htm','toolbar=no,width=450,height=626,left=50,top=50,

status=no,scrollbars=no,resize=no')

Multiline Strings in JavaScript don't work. You should either put all of that on one line or use the plus operator to concentrate the string parts together.
Copy linkTweet thisAlerts:
@JamesOneauthorMay 22.2005 — I´m not really sure of how you mean but now I did put the lines together, still not functioning though.
Copy linkTweet thisAlerts:
@UltimaterMay 22.2005 — It looks like it's functioning well to me. I click a dot and a pop-up window pops up with the correct URL. ?
Copy linkTweet thisAlerts:
@JamesOneauthorMay 22.2005 — Yes, now I finally got it to work somehow ?

Got a bit confused there with the code.

Thankyou SO much for your help with the problems!

Peace
×

Success!

Help @JamesOne 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.18,
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,
)...