PDA

View Full Version : DIV functions



iUnknown
29-02-2008, 07:32 PM
Hello,

I currently have a website with some content in a DIV. The content in the DIV is a code that will link to a different site, and changes every so often but not by me. I need it so that when of one of the links inside it are clicked, it opens the link and does a javascript function. So far, the best I can do is putting the html code in a DIV and making the "onmouseout" of the div run the javascript function. However, this does not work well in firefox and people are just moving their mouse over and away from the div instead of clicking the links. Is there a better way of doing this, ie. onclick command to run the javascript function?

Successfuly helpers will receive +rep as thanks.

Thanks in advance.

Hypertext
29-02-2008, 10:11 PM
in the a href use onrelease i think

iUnknown
29-02-2008, 10:22 PM
Will try onrelease instead of onmouseout - one second ;) thanks.

Edit: Nope, nothing happens now.

Edit2: Just found a command "ondblclick", what does this do? Might it work where onclick doesn't?

Edit3: Oh, it's just on double click.

By the way, onclick doesn't work. This would definitely be the most practicle. Is there possibly something I could put in CSS, and make the div have an ID/class?

Florx
29-02-2008, 10:28 PM
Lets see the site and we might be able to help you :)

Invent
29-02-2008, 10:31 PM
<a href="page.php" onmousedown="function();" onclick="function2();">lol</a>

:S ?

iUnknown
29-02-2008, 10:32 PM
*removed by me*



<a href="page.php" onmousedown="function();" onclick="function2();">lol</a>:S ?

It's a challenge due to the content inside the DIV, it's not any ordinary link.

Invent
29-02-2008, 10:41 PM
URL please as I don't understand what's so complicated.

MrCraig
29-02-2008, 10:46 PM
Oh sorry guy, i said id look at this for you..

Give me 2 secs.

Just checking the code on my server, as i think its your javascript thats stopping the onclick from functioning.
then il pm you code when done..

iUnknown
29-02-2008, 10:54 PM
Oh sorry guy, i said id look at this for you..

Give me 2 secs.

Just checking the code on my server, as i think its your javascript thats stopping the onclick from functioning.
then il pm you code when done..

Thanks Craig, once again ^^ :D

MrCraig
29-02-2008, 10:55 PM
nps, just waiting for brute force protection to unlock me... :|

Hypertext
29-02-2008, 11:03 PM
<a href="x.html" onmouseup="functiona()" onmousedown="function()" class="myclass">MY LINK!</a>

iUnknown
29-02-2008, 11:15 PM
Reconix, thanks but no thanks. That won't work, I don't have control of the link. Think of it like it's in an iframe.

Craig's working on it for me anyway now :P

MrCraig
29-02-2008, 11:24 PM
Guy, i think the javascript behind the ad is preventing the onclick function from working sorry :S

I dont really know what to suggest :S

Hypertext
29-02-2008, 11:31 PM
Hehe, your screwed :( boo..

iUnknown
29-02-2008, 11:39 PM
Is there some way of "onEvent" or possibly putting it in a table or something?

MrCraig
29-02-2008, 11:44 PM
its not that, its just when anywhere inside the ad is clicked, the ad javascript overtakes any previous onclick functions..

I could put it inside 20 tables and 30 divs each with an onclick but as long as its the inside of the ad thats being clicked, thats the JS that will run.

Blob
01-03-2008, 10:31 AM
<a href="x.html" onmouseup="functiona() return false;" onmousedown="function() return false;" class="myclass">MY LINK!</a>

That will make it so it goes to x.html if you don't have javascript enabled.

iUnknown
01-03-2008, 02:40 PM
<a href="x.html" onmouseup="functiona() return false;" onmousedown="function() return false;" class="myclass">MY LINK!</a>

That will make it so it goes to x.html if you don't have javascript enabled.

Why have you put onmouseup/onmousedown there? And also Craig, onmouseout works.. even after they've clicked the ad. In internet explorer, you can click it then close the new window and voila it'd have run the javascript function by then because it's onmouseout, when you move the mouse away to close the new window.

Blob
01-03-2008, 02:43 PM
Why have you put onmouseup/onmousedown there? And also Craig, onmouseout works.. even after they've clicked the ad. In internet explorer, you can click it then close the new window and voila it'd have run the javascript function by then because it's onmouseout, when you move the mouse away to close the new window.

I copied Reconix' code.

MrCraig
01-03-2008, 05:06 PM
i know onmouseout works. But onclick doesnt which is the whole point of people having to click it..

iUnknown
02-03-2008, 01:13 PM
i know onmouseout works. But onclick doesnt which is the whole point of people having to click it..

Hmm. Any ideas like.. putting it in an iframe and making "onclick" the div with the iframe in do it? Think that would work?

Want to hide these adverts? Register an account for free!