View Full Version : Plz Help Me Clean Up My Script

02-05-2007, 07:08 AM
I am pretty new to Javascript so this is some ugly code I wrote to do the purpose I desired. You can probably get the drift of the code if you look into it. I am having problems with all the timeouts because sometimes they don't happen in the right order. I was wondering if it would be better to use if/then statements to check the url of the iframes to see if they have loaded before executing next command.

Please, Please Help me with this!

I supposed I should explain all of this more clearly first..
function rr= textbox and button for loading rating info of specified user in Iframe "ratingfrm"
function manlogin= login form for yahoo users which targets a hidden iframe "loginframe". This must do several things in order:
1.Log out of yahoo in "loginframe".
2.Submit login form in "loginframe" Only after step 1 is finished.
3.UNhide "loginframe" after step 2.
4.Change url of Iframe-"ratingfrm" based on value of user on form.

<script type="text/javascript">
function rr(){
var ratename=document.rateform.ratebox.value;

function manlogin(){
sn=document.manlog.login.value; addy=window.ratingfrm.location="http://profiles.games.yahoo.com/games/profile2?name="+sn+"&intl=us&consolidater=spades.yahoo";

function hideiframe(element) {
var style;

if (typeof element == 'string')
element = document.getElementById ? document.getElementById(element) : null;
if (element && (style = element.style))
style.display = (style.display == 'none') ? '' : 'none';


02-05-2007, 10:46 AM
I'm not going to try rewriting that code so that it works. I will say that time outs are not multi-threaded. This means that while one is waiting, so are the others. In fact, sometimes when one is waiting, others will not even begin to wait. So, instead of having:


You should probably have:


Then, at the end (or possibly at the beginning) of document.manlog.submit(), have:


This of course would require addy be made into a function.

There could be other problems.