I have this issue in two places now, so i figured i would ask and see if anyone has the same issues...
So on a page i might have a button or link with both a href and an onclick event. When the user Physically clicks the link it behaves how i would expect by executing both the href and the onclick event. But if for some reason i need to trigger/call the link by a virtual .click() event, it only does the onClick and not the href.
as a simple example, if you have a page like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional-dtd">
<a href="http://www.google.com" target="_blank" onclick="document.location.href='http://jquery.com/'" id="testClickLink">Click here to open Google in a new window and jQuery in this window</a>
</body>
</html>
When it loads it will load jQuery in this window but not do anything with Google. If you remove ' $('#testClickLink').click();' from the code, and just click the link yourself it will load as expected.
So i am not sure if this is a known issue or is expected behavior, but i would think that a physical click and a virtual click should act the same.
Alternatively, if anyone knows how to trigger on page load a new tab/window (not a pop-up but target="_Blank"), and also use the history.back(); for the parent page? I am kinda stuck.... If the .click event would work on my link i would be set...
UPDATE: i am not looking for window.open, i am looking for the same functionally as target="_blank" on a link, which acts as a new tab in IE/FF and does not get blocked by a pop up blocker.
SO when the page loads, it both, sends the user to a new tab with the href attribute, and reloads the old parent page(page they were redirected from) to something else (or in my case, sending them back to the previous page).
I have some simple code to make a link open on page load. When the code fires it shows the alert 'clicked' but then nothing happens. The url is generated with APEX and if i click the link on the page physically the alert fires and the page redirects to the linked Url. Why isn't the click event working?
I am having trouble figuring out how to correct this error, i think i have narrowed it down to what function is causing the issue, since once i comment it out, it doent give the error, but the code no longer does what its supposted to. Whats weird is that the code works how it should even with the error, but i dont want any errors even if they arnet effecting anything... well here is the code: $(document).ready(function(){ //every time a textbox is clicked or focused... $('.tbox').bind('click focus',function(){ //get the focused textbox's outer border var targetThis = $(this).parent().parent().parent().parent(); HandleBlueMe(targetThis ,true); }); function HandleBlueMe(CurrentBoxWithInput,blnOn){ if(CurrentBoxWithInput != null){ if(blnOn == true){ removePreviousFocusedBlue(CurrentBoxWithInput); activateBlue(CurrentBoxWithInput); }else if(blnOn == false){ deactivateBlue(CurrentBoxWithInput); } } } function activateBlue(Box){ //debugger; $(Box).select('.box').addClass('active'); } function deactivateBlue(Box){ $(Box).select('.box').removeClass('active'); } function removePreviousFocusedBlueForInput(){ $('.sprite > .box').removeClass('active'); } function removePreviousFocusedBlue(CurrentBoxWithInput){ if(CurrentBoxWithInput != null && $(CurrentBoxWithInput).select ('.box').length > 0){ //alert('remove input blue input'); removePreviousFocusedBlueForInput(); }else{alert('CurrentBoxWithInput = null or length is less than zero');} } function GetInputContainer(input){ try{ return $(input).parent().parent().parent().parent(); }catch(ex){ alert("JAVASCRIPT ERROR FAILED TO GET INPUT CONTAINER: "+ex.message); } return null; } here is a sample of the HTML that it is using: <div class="sprite inputOne"> <div class="box textbox" id="boxOne"> <div class="topcorners"> <div> <div></div> </div> </div> <div class="middle"> <div class="left"> <div class="right group1"> <input class="inputBox tbox regemail rec" id="Name" required="true" title="Full Name"/> </div> </div> </div> <div class="bottomcorners"> <div> <div></div> </div> </div> </div>
I am stuck with an issue of getting my modal to pop up and out of the iframe and show on top of the parent page. I am using the jqModal and you seem to have answers for everything but this... I have a parent page, that i can not edit, with an iframe that contains the logic for the modal. When the the modal is triggered, it only shows inside of the iframe and i cant seem to get it to pop up over the parent window. This is the ultimate objective: OnLoad of the parent page, if something=true to pop up the modal from within the iframe to show over the parent. I can get it to do everything that i need it to do BUT pop up outside of the iframe. ...idk... i think i am just running in circles at this point.... SO here is the simplified code that is nested inside of the parent iframe.... it loads the modal onLoad of the page, but its inside the iframe... :-( [HTML] <style> .jqmWindow {display: none; position: fixed; top: 17%; left: 50%; width: 510px; margin-left: -300px; background-color: #FFFFFF; color: #333; border: 1px solid black; padding:0px 10px 10px 10px;} .jqmOverlay {background-color: #000;} </style> <script type="text/javascript"> $(window).load(function(){ $('#dialog').jqm(); $('#dialog').jqmShow(); }); </script> <div id="dialog" class="jqmWindow"> Content of Modal would go here. </div> [/HTML]