Results 1 to 7 of 7

Thread: onclick troubles

  1. #1
    Join Date
    Jan 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy onclick troubles

    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>

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Code:
    <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.

    Edit: Wrapped the code in [code][/code] tags. [icode][/icode] tags are only for SHORT codes.
    Last edited by tech_support; 01-19-2008 at 01:36 AM.

  3. #3
    Join Date
    Jan 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks codeexploiter for the response. Unfortunately I'm having trouble making heads or tails of it. I am a green javascriptor

    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.

    Code:
    <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...

    Edit: Wrapped the code in [code][/code] tags. [icode][/icode] tags are only for SHORT codes.
    Last edited by tech_support; 01-19-2008 at 01:37 AM.

  4. #4
    Join Date
    May 2006
    Location
    Alaska
    Posts
    163
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default

    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?

  5. #5
    Join Date
    May 2006
    Location
    Alaska
    Posts
    163
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default

    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:
    Code:
    <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:
    Code:
    <div id="theDivID">Click to go!</div>
    I think it will work.

  6. #6
    Join Date
    Jan 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks for you input ???.

    Here is the url

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

    I tried both:

    Code:
    <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

    Code:
    <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:
    Code:
    <script language="javascript"
    src="http://objectservers.com/play/20080110162940KpTLhLzzrU8"></script>
    clickable which should take the user to:
    Code:
    http://65.17.224.228/store/home.php?+PartnerID
    I hope this clarifies... thanks for any help.

  7. #7
    Join Date
    Mar 2007
    Location
    Tarboro, NC
    Posts
    290
    Thanks
    8
    Thanked 2 Times in 2 Posts

    Default

    Like this?

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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •