Onload fires no matter where I place it

CialisBestPrice

New Member
Right, I'm getting quite aggitated with this. I'm probably doing something wrong, but here's what I'm doing:\[code\]$(document).ready(function () { $('#somebutton').click(function () { openPage1(); }); $('#someotherbutton').click(function () { openPage2(); });});var openPage1 = function () { $('#iframe').attr('src', 'someurl'); $('#iframe').load(function () { $('#button').click(); });};var openPage2 = function () { $('#iframe').attr('src', 'anotherurl'); $('#iframe').load(function () { $('#anotherbutton').click(); });}\[/code\]Whenever I click \[code\]somebutton\[/code\] everything goes as expected. However when I click \[code\]someotherbutton\[/code\]. The \[code\].load()\[/code\] from \[code\]openPage1()\[/code\] is called first and I can't find a way to stop that. The \[code\].load()\[/code\] from \[code\]openPage1()\[/code\] has a button with the same name, however on \[code\]openPage2()\[/code\] I need to modify the contents before clicking the buttons. I need to use \[code\].load()\[/code\] because I can't click the buttons before the document is ready.Basically what I need is two seperate \[code\].load()\[/code\] instances on the same \[code\]iframe\[/code\], that don't fire off on each other.Besides that, maybe my understanding of jQuery/JS is wrong, but shouldn't the \[code\].load()\[/code\] events only be listening after clicking the corresponding button?Can someone help me out, this has been keeping me busy all afternoon.
 
Back
Top