[jQuery] Re: Triggering a link with no click event
Hi all, click() doesn't work on most browsers because of security reasons. Can you imagine giving some spam programmer the ability to simulate a mouse click? cheers Michael Lawson Content Tools Developer, Global Solutions, ibm.com Phone: 1-919-517-1568 Tieline: 255-1568 E-mail: mjlaw...@us.ibm.com 'Examine my teachings critically, as a gold assayer would test gold. If you find they make sense, conform to your experience, and don't harm yourself or others, only then should you accept them.' From: solidhex To: "jQuery (English)" Date: 02/09/2009 02:01 PM Subject:[jQuery] Re: Triggering a link with no click event I was looking to do the same thing - I wanted to emulate the click() method, which doesn't work on all browsers. I have had any luck either. I was trying to open a file input browse view by clicking on another link. I can get it to work in IE and Safari, but Firefox doesn't support it on input[type=file] On Jan 31, 2:23 pm, Andy789 wrote: > Guys, thank you, but it still does not work. > > 1) The Maurício's solution is just a way of extracting the href value > and creating onlick event to jump to that link. What I need is to > emulate aclickon the a element without opening a link directly. The > reason for that: Rokbox scans all rel="rokbox" elements and generates > a set of divs bevore closing body tag. Somehow the links are binded > with some internal RokBox functions, so clicking on the link opens a > RokBox with the link target inside. > > 2) Yes, I am using both mootools and jquery with noConflict() > declaration - it works perfectly > > 3) The problem is that I cannot find the function inside RokBox to > call it directly from jscript function. At the same time I would > rather prefer to use RokBox, because it works perfectly for complex > independent pages with ajax, flash etc inside. RokBox creates an > iframe inside. > > The point is that I need to find either a way of emulating the linkclickor a function inside RokBox, which is difficult, because it is > packed > > any more ideas? <><>
[jQuery] Re: Triggering a link with no click event
I was looking to do the same thing - I wanted to emulate the click() method, which doesn't work on all browsers. I have had any luck either. I was trying to open a file input browse view by clicking on another link. I can get it to work in IE and Safari, but Firefox doesn't support it on input[type=file] On Jan 31, 2:23 pm, Andy789 wrote: > Guys, thank you, but it still does not work. > > 1) The Maurício's solution is just a way of extracting the href value > and creating onlick event to jump to that link. What I need is to > emulate aclickon the a element without opening a link directly. The > reason for that: Rokbox scans all rel="rokbox" elements and generates > a set of divs bevore closing body tag. Somehow the links are binded > with some internal RokBox functions, so clicking on the link opens a > RokBox with the link target inside. > > 2) Yes, I am using both mootools and jquery with noConflict() > declaration - it works perfectly > > 3) The problem is that I cannot find the function inside RokBox to > call it directly from jscript function. At the same time I would > rather prefer to use RokBox, because it works perfectly for complex > independent pages with ajax, flash etc inside. RokBox creates an > iframe inside. > > The point is that I need to find either a way of emulating the linkclickor a > function inside RokBox, which is difficult, because it is > packed > > any more ideas?
[jQuery] Re: Triggering a link with no click event
Guys, thank you, but it still does not work. 1) The Maurício's solution is just a way of extracting the href value and creating onlick event to jump to that link. What I need is to emulate a click on the a element without opening a link directly. The reason for that: Rokbox scans all rel="rokbox" elements and generates a set of divs bevore closing body tag. Somehow the links are binded with some internal RokBox functions, so clicking on the link opens a RokBox with the link target inside. 2) Yes, I am using both mootools and jquery with noConflict() declaration - it works perfectly 3) The problem is that I cannot find the function inside RokBox to call it directly from jscript function. At the same time I would rather prefer to use RokBox, because it works perfectly for complex independent pages with ajax, flash etc inside. RokBox creates an iframe inside. The point is that I need to find either a way of emulating the link click or a function inside RokBox, which is difficult, because it is packed any more ideas?
[jQuery] Re: Triggering a link with no click event
I'm not sure, but I think click() will only fire the events bound with jQuery itself. RokBox seems to be based on mootools, have you tried the mootools way? $('test').fireEvent('click'); Also, are you sure you're not having conflicts between jQuery and mootools? Which one is using the caret symbol ($)? Best would be to stick to a single library, as you'll have overlapping functionality (longer download times) and the possibility of problems like this. On Jan 31, 5:38 am, Andy789 wrote: > As I can see quite many posts on this subject I wanted to explain why > I need this. I generate links for RokBox modal window - something like > > test > > next, I need to trigger these links from jscript function (from the > external flash application). I could not figure out the way how to > call RokBox directly and have to finc out the way how to trigger links > via jquery or mootools or whatsoever. > > Any suggestions?
[jQuery] Re: Triggering a link with no click event
Hi Andy, Sorry. There is no need to use the find() method. function linkClick() { var target = $('#test').attr('href'); window.location = target; } --- But I strongly recommend do not use javascrit whitin the markup. Keep behavior inside its own layer. So a best approach should be: Markup layer Emulating click Behavior layer: $(document).ready(function(){ $('#linktest').click(function() { var target = $('#test').attr('href'); window.location = target; }); }); -Mensagem Original- De: "Andy789" Para: "jQuery (English)" Enviada em: sábado, 31 de janeiro de 2009 05:15 Assunto: [jQuery] Triggering a link with no click event HI All, It could be a silly question, but I cannot find a simple answer... I need to trigger a link with href via an external function, i.e. Emulating click my link function linkClick(){ $("#test").click(); } It does not work and returns nothing. I understanbd that it is because the a#test does not have the actual onclick event. So, how can I emulate click on a#test? Note, that I cannot modify the a link element or add onclick events.
[jQuery] Re: Triggering a link with no click event
Try: function linkClick() { var target = $('body').find('#test').attr('href'); window.location = target; } Maurício -Mensagem Original- De: "Andy789" Para: "jQuery (English)" Enviada em: sábado, 31 de janeiro de 2009 05:15 Assunto: [jQuery] Triggering a link with no click event HI All, It could be a silly question, but I cannot find a simple answer... I need to trigger a link with href via an external function, i.e. Emulating click my link function linkClick(){ $("#test").click(); } It does not work and returns nothing. I understanbd that it is because the a#test does not have the actual onclick event. So, how can I emulate click on a#test? Note, that I cannot modify the a link element or add onclick events.
[jQuery] Re: Triggering a link with no click event
As I can see quite many posts on this subject I wanted to explain why I need this. I generate links for RokBox modal window - something like test next, I need to trigger these links from jscript function (from the external flash application). I could not figure out the way how to call RokBox directly and have to finc out the way how to trigger links via jquery or mootools or whatsoever. Any suggestions?