![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Alright so I'm far from a jQuery pro and this is what I'm trying to do; I'm using Colorbox to display content in a 'lightbox' script type="text/javascript" var WindowShown = 0; $(document).ready(function(){ $(".iframe").colorbox({innerWidth:"810px", innerHeight:"580px", iframe:true}); }); /script and here's my code p> http://www.disney.com Outside webpage (IFrame) </p This works excellent, the iframe content comes up within the lightbox (as defined in an external colorbox javascript file) UPON clicking the 'outside webpage (IFrame)' link. So I'm good until there. But, what I'm trying to do is have the iframe show up when the user moves his/her mouse outside of the viewable area. I have the code for that and it's working fine and basically at the end it has the ability to run a function e.g. 'lastchance();' My question is, how do I tell the lastchance function to 'click' the iframe-class link? I've tried doing it with: document.getElementById('clickme').click(); but to no avail I know jquery supports other events like onload, onmouseover, etc. but I need to trigger my jquery event (the lightbox) from a non-jquery piece of code. Help! -- View this message in context: http://old.nabble.com/simple-question-regarding-trigger-jquery-events-with-non-jquery-code-tp26230150s27240p26230150.html Sent from the jQuery General Discussion mailing list archive at Nabble.com. |
#3
| |||
| |||
|
|
Use jQuery in the first place : document.getElementById() doesn't wrap what it finds in the jQuery result array so there's no jQuery .click() method for your result. So use jQuery selectors like this : $('#clickme').click(); |
#4
| |||
| |||
|
|
Thank you so much for your response Michel. Being the complete noob that I am though I can't seem to implement it as desired. The code works fine when I put it in my document ready function like; $(document).ready(function(){ $(".iframe").colorbox({innerWidth:"810px", innerHeight:"580px", iframe:true}, function(){WindowShown=1;}); $('#clickme').click(); }); Ofcourse this way it loads as soon as the page loads (or before it finishes loading even). But how do I 'trigger' the click only upon a certain event? Let's say when my other javascript calls LastChance(); ? E.g. $(document).ready(function(){ $(".iframe").colorbox({innerWidth:"810px", innerHeight:"580px", iframe:true}, function(){WindowShown=1;}); }); function LastChance() { // execute the event! $('#clickme').click(); } And then when my other piece of javascript triggers LastChance function it does the .click() stuff. Do you get what I'm saying? Sorry for the noob question, I'm sure the answer is really simple. Is there a jquery for dummies book? ![]() Michel Belleville wrote: Use jQuery in the first place : document.getElementById() doesn't wrap what it finds in the jQuery result array so there's no jQuery .click() method for your result. So use jQuery selectors like this : $('#clickme').click(); -- View this message in context: http://old.nabble.com/simple-question-regarding-trigger-jquery-events-with-non-jquery-code-tp26230150s27240p26230906.html Sent from the jQuery General Discussion mailing list archive at Nabble.com. |
#5
| |||
| |||
|
|
Thank you so much for your response Michel. Being the complete noob that I am though I can't seem to implement it as desired. The code works fine when I put it in my document ready function like; $(document).ready(function(){ * * * * $(".iframe").colorbox({innerWidth:"810px", innerHeight:"580px", iframe:true}, function(){WindowShown=1;}); * * * * $('#clickme').click(); }); Ofcourse this way it loads as soon as the page loads (or before it finishes loading even). But how do I 'trigger' the click only upon a certain event? Let's say when my other javascript calls LastChance(); ? E.g. $(document).ready(function(){ * * * * $(".iframe").colorbox({innerWidth:"810px", innerHeight:"580px", iframe:true}, function(){WindowShown=1;}); }); function LastChance() { // execute the event! * * * * $('#clickme').click(); } And then when my other piece of javascript triggers LastChance function it does the .click() stuff. Do you get what I'm saying? Sorry for the noob question, I'm sure the answer is really simple. Is there a jquery for dummies book? ![]() Michel Belleville wrote: Use jQuery in the first place : document.getElementById() doesn't wrap what it finds in the jQuery result array so there's no jQuery .click() method for your result. So use jQuery selectors like this : $('#clickme').click(); -- View this message in context:http://old.nabble.com/simple-question-regarding-trigger-jquery-events... Sent from the jQuery General Discussion mailing list archive at Nabble.com. |
#6
| |||
| |||
|
|
I'm not sure if I under stand you. Are you trying to trigger the click event inside another event ? if so then you do it like this $('selector').blur(function(){ $('#clickme').click(); }); blur is just an example here you can use what ever event you like for this. list of events http://docs.jquery.com/Events with regards Bjarki Heiðar On Nov 6, 9:42Â*pm, jQueryNoobzor <warko... (AT) gmail (DOT) com> wrote: Thank you so much for your response Michel. Being the complete noob that I am though I can't seem to implement it as desired. The code works fine when I put it in my document ready function like; $(document).ready(function(){ Â* Â* Â* Â* $(".iframe").colorbox({innerWidth:"810px", innerHeight:"580px", iframe:true}, function(){WindowShown=1;}); Â* Â* Â* Â* $('#clickme').click(); }); Ofcourse this way it loads as soon as the page loads (or before it finishes loading even). But how do I 'trigger' the click only upon a certain event? Let's say when my other javascript calls LastChance(); ? E.g. $(document).ready(function(){ Â* Â* Â* Â* $(".iframe").colorbox({innerWidth:"810px", innerHeight:"580px", iframe:true}, function(){WindowShown=1;}); }); function LastChance() { // execute the event! Â* Â* Â* Â* $('#clickme').click(); } And then when my other piece of javascript triggers LastChance function it does the .click() stuff. Do you get what I'm saying? Sorry for the noob question, I'm sure the answer is really simple. Is there a jquery for dummies book? ![]() Michel Belleville wrote: Use jQuery in the first place : document.getElementById() doesn't wrap what it finds in the jQuery result array so there's no jQuery .click() method for your result. So use jQuery selectors like this : $('#clickme').click(); -- View this message in context:http://old.nabble.com/simple-question-regarding-trigger-jquery-events... Sent from the jQuery General Discussion mailing list archive at Nabble.com. |
#7
| |||
| |||
|
|
Thank you but the problem is that it's not an event detectable by jquery as far as I know. It's an event that I have a script for and it triggers when the mouse moves towards a tab or the close window, but NOT when it moves to the left, right or bottom of the browser's viewable area. So I just need to 'execute' a jquery event ( the .click) from a non-jquery piece of code. Sorry for making it sound complicated ![]() Bjarki-2 wrote: I'm not sure if I under stand you. Are you trying to trigger the click event inside another event ? if so then you do it like this $('selector').blur(function(){ $('#clickme').click(); }); blur is just an example here you can use what ever event you like for this. list of events http://docs.jquery.com/Events with regards Bjarki Heiðar On Nov 6, 9:42 pm, jQueryNoobzor <warko... (AT) gmail (DOT) com> wrote: Thank you so much for your response Michel. Being the complete noob that I am though I can't seem to implement it as desired. The code works fine when I put it in my document ready function like; $(document).ready(function(){ $(".iframe").colorbox({innerWidth:"810px", innerHeight:"580px", iframe:true}, function(){WindowShown=1;}); $('#clickme').click(); }); Ofcourse this way it loads as soon as the page loads (or before it finishes loading even). But how do I 'trigger' the click only upon a certain event? Let's say when my other javascript calls LastChance(); ? E.g. $(document).ready(function(){ $(".iframe").colorbox({innerWidth:"810px", innerHeight:"580px", iframe:true}, function(){WindowShown=1;}); }); function LastChance() { // execute the event! $('#clickme').click(); } And then when my other piece of javascript triggers LastChance function it does the .click() stuff. Do you get what I'm saying? Sorry for the noob question, I'm sure the answer is really simple. Is there a jquery for dummies book? ![]() Michel Belleville wrote: Use jQuery in the first place : document.getElementById() doesn't wrap what it finds in the jQuery result array so there's no jQuery .click() method for your result. So use jQuery selectors like this : $('#clickme').click(); -- View this message in context: http://old.nabble.com/simple-question-regarding-trigger-jquery-events... Sent from the jQuery General Discussion mailing list archive at Nabble.com. -- View this message in context: http://old.nabble.com/simple-question-regarding-trigger-jquery-events-with-non-jquery-code-tp26230150s27240p26251933.html Sent from the jQuery General Discussion mailing list archive at Nabble.com. |
![]() |
| Thread Tools | |
| Display Modes | |
| |