PDA

View Full Version : onclick troubles



totus
01-17-2008, 06:15 AM
I'm new at this and was wondering if anyone could help. I cannot get the onclick function to work properly. I'm sure its something simple. Can anyone help? I am needing the video object that is playing to take the user to a url with an appended affiliate ID when they click on it.

<script language=javascript>
var HTWmsi = "demo"; // unbrands the player
var PartnerID = "bid=1&partner=yoda"; // put the partner ID from your system in these quotes
function onClick(){
window.location.href="http://65.17.224.228/store/home.php?+PartnerID"
}
</script>
<script language="javascript"
src="http://objectservers.com/play/20080110162940KpTLhLzzrU8"></script>

codeexploiter
01-17-2008, 07:01 AM
<script type="text/javascript">
var eventRegInit = function(){
document.getElementById('myDiv').onclick = myDivOnClick;
}

var myDivOnClick = function(){
alert('You've clicked myDiv');
}

window.onload = eventRegInit;
</script>

The above code calls the 'eventRegInit' function as a part of window's onload event. The function creates an event listener for the onclick event on an element named 'myDiv' and whenever someone clicks on that element it will execute 'myDivOnClick' function. This is just a small example how these things works. You can specify the events either in JavaScript or as a part of the HTML. Personally I prefer the JavaScript based one as it helps me to seperate the HTML content form the JavaScript part.

Wrapped the code in
tags. tags are only for SHORT codes.

totus
01-18-2008, 10:51 PM
Thanks codeexploiter for the response. Unfortunately I'm having trouble making heads or tails of it. I am a green javascriptor :confused:

Basically what I'm trying to do is make the object that is bold and italisized below clickable once it loads. When some clicks on it, it will take them to the url specified.


<script language=javascript>
var HTWmsi = "demo"; // unbrands the player
var PartnerID = "bid=1&partner=yoda"; // put the partner ID from your system in these quotes
function onClick(){
window.location.href="http://65.17.224.228/store/home.php?+PartnerID"
}
</script>
<script language="javascript"
src="http://objectservers.com/play/20080110162940KpTLhLzzrU8"></script>

I do appreciate any input, sorry for my ignorance...

Wrapped the code in
tags. tags are only for SHORT codes.

???
01-19-2008, 06:04 PM
Well, you're saying you want people to click the script object? Where do you want the user to go to when they click it? Or does that script do document.write?

???
01-19-2008, 06:12 PM
Without that odd script, if you click the thing that says "Click to go" it will take you to the url you have. This goes in the head:
<script type="text/javascript">
var PartnerID = "bid=1&partner=yoda"; // put the partner ID from your system in these quotes
window.onload = function () {
document.getElementById ("theDivID").onclick = function () {
window.location.href="http://65.17.224.228/store/home.php?+PartnerID"
}
}
</script>

This goes in the body:

<div id="theDivID">Click to go!</div>

I think it will work.

totus
01-19-2008, 10:23 PM
Thanks for you input ???.

Here is the url

http://www.totus.us/website-video-sales-person.html

I tried both:


<script type="text/javascript">
var PartnerID = "bid=1&partner=yoda"; // put the partner ID from your system in these quotes
window.onload = function () {
document.getElementById ("theDivID").onclick = function () {
window.location.href="http://65.17.224.228/store/home.php?+PartnerID"
}
}
</script>
<div id="theDivID">Click to go!</div>

and


<script type="text/javascript">
var HTWmsi = "demo"; // unbrands the player
var PartnerID = "bid=1&partner=yoda"; // put the partner ID from your system in these quotes
window.onload = function () {
document.getElementById ("theDivID").onclick = function () {
window.location.href="http://65.17.224.228/store/home.php?+PartnerID"
}
}
</script>
<div id="theDivID"><script language="javascript"
src="http://objectservers.com/play/20080110162940KpTLhLzzrU8"></script></div>

without success.

Essentially what I'm trying to do is make the video object that gets loaded by:
<script language="javascript"
src="http://objectservers.com/play/20080110162940KpTLhLzzrU8"></script> clickable which should take the user to:
http://65.17.224.228/store/home.php?+PartnerID

I hope this clarifies... thanks for any help.

TimFA
01-19-2008, 10:34 PM
Like this?



<div id="w.e." onclick="window.location='http://65.17.224.228/store/home.php?+PartnerID';">
content
</div>


Or something more complicated/what?