vbGore Free Online RPG Engine

Revolutionizing Visual Basic ORPG Development
It is currently Thu May 23, 2013 7:36 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: javascript not working
PostPosted: Thu Aug 06, 2009 8:59 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
Code:
<?php
define("IN_MYBB", 1);
define("NO_ONLINE", 1);
require("forums/global.php");
if(!$mybb->user['uid'])
{
echo "<form name='login' action='forums/member.php' method='post'>
<table width='100%' border='0'>
<tr>
<td colspan='2' height='30px' background='/forums/images/ArchGames/thead_bg.png'>
<a href=''><img border='0' style='float: right;' onclick='self.parent.tb_remove();' src='/images/close.png' /></a>
</td>
</tr>
<tr>
<td align='right'>
Username:
</td>
<td align='left'>
<input type='text' name='username' size='25' maxlength='30' />
</td>
</tr>
<tr>
<td align='right'>
Password:
</td>
<td align='left'>
<input type='password' name='password' size='25' />
</td>
</tr>
<tr>
<td colspan='2'>
<input type='hidden' name='action' value='do_login'>
<input type='hidden' name='url' value='' />
<input type='submit' class='submit' name='submit' value='Login' />
</td>
</tr>
</table>
</form>";
}
?>
<script type="text/javascript">
document.login.url.value = parent.location.href;
</script>


Anyone know why?


Last edited by notexistant on Sat Aug 08, 2009 2:30 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: javascript not running
PostPosted: Fri Aug 07, 2009 1:18 am 
=^.^= Kitty =^.^=

Joined: Tue Mar 20, 2007 10:46 pm
Posts: 1821
Location: Sydney Australia
change

parent.location.href

to

window.location.href

or window.location is fine in itself.

But I assume your using an iFrame so

parent.window.location.href


Top
 Profile  
 
 Post subject: Re: javascript not running
PostPosted: Fri Aug 07, 2009 4:14 am 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
Nope, still didn't work.


Top
 Profile  
 
 Post subject: Re: javascript not running
PostPosted: Fri Aug 07, 2009 1:12 pm 
=^.^= Kitty =^.^=

Joined: Tue Mar 20, 2007 10:46 pm
Posts: 1821
Location: Sydney Australia
Oh shit I wasn't thinking properly, you have to access objects using the DOM standard, the method you pulled only works in something like firefox I think.

Code:
<?php
define("IN_MYBB", 1);
define("NO_ONLINE", 1);
require("forums/global.php");
if(!$mybb->user['uid'])
{
echo "<form name='login' action='forums/member.php' method='post'>
<table width='100%' border='0'>
<tr>
<td colspan='2' height='30px' background='/forums/images/ArchGames/thead_bg.png'>
<a href=''><img border='0' style='float: right;' onclick='self.parent.tb_remove();' src='/images/close.png' /></a>
</td>
</tr>
<tr>
<td align='right'>
Username:
</td>
<td align='left'>
<input type='text' name='username' size='25' maxlength='30' />
</td>
</tr>
<tr>
<td align='right'>
Password:
</td>
<td align='left'>
<input type='password' name='password' size='25' />
</td>
</tr>
<tr>
<td colspan='2'>
<input type='hidden' name='action' value='do_login'>
<input type='hidden' name='url' value='' />
<input type='submit' class='submit' name='submit' value='Login' />
</td>
</tr>
</table>
</form>";
}
?>
<script type="text/javascript">
var o_url  = document.getElementsByName['url'][0]
o_url.value = parent.location.href;
</script>



Right I wasn't thinking last night sorry.


Top
 Profile  
 
 Post subject: Re: javascript not running
PostPosted: Fri Aug 07, 2009 1:14 pm 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
You see it doesn't work an I'm using firefox. Also even a simple alert message doesn't show. I'll try what you posted when I get home though.


Top
 Profile  
 
 Post subject: Re: javascript not running
PostPosted: Fri Aug 07, 2009 1:38 pm 
=^.^= Kitty =^.^=

Joined: Tue Mar 20, 2007 10:46 pm
Posts: 1821
Location: Sydney Australia
It was either an old method in firefox or IE I forget, but its unsupported.

Also if you want a better understanding of your errors try


try {
...
} catch (ex) {
alert(ex.message);
}


Top
 Profile  
 
 Post subject: Re: javascript not running
PostPosted: Sat Aug 08, 2009 1:41 am 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
Your code...
Code:
<script type="text/javascript">
var o_url  = document.getElementsByName['url'][0]
o_url.value = parent.location.href;
</script>


Returns:
Quote:
document.getElementsByName.url is undefined

The one I was using returns no error is just doesn't work. The source reads...
Code:
<input type='hidden' name='url' value='' />

When it should read...
Code:
<ingput type='hidden' name='url' value='http://arch-games.com' />

Also the first code you gave me also returns no error it just doesn't set value to the parent frame like my first issue. If I change it to an alert box like so...
Code:
<script type="text/javascript">
alert(parent.window.location.href);
</script>

or
Code:
<script type="text/javascript">
alert(parent.location.href);
</script>

Both give me the correct url.


Top
 Profile  
 
 Post subject: Re: javascript not working
PostPosted: Sat Aug 08, 2009 2:49 am 
=^.^= Kitty =^.^=

Joined: Tue Mar 20, 2007 10:46 pm
Posts: 1821
Location: Sydney Australia
Ok WHAT kind of browser are you even using? [and best of all what version]

It shouldn't even return 'document.getElementsByName.url is undefined', in that written format.


Top
 Profile  
 
 Post subject: Re: javascript not working
PostPosted: Sat Aug 08, 2009 2:58 am 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
Firefox 3.5

Also IE 8 says...
Attachment:
ie.PNG


Top
 Profile  
 
 Post subject: Re: javascript not working
PostPosted: Sat Aug 08, 2009 3:14 pm 
=^.^= Kitty =^.^=

Joined: Tue Mar 20, 2007 10:46 pm
Posts: 1821
Location: Sydney Australia
Oh man I never check before I wrote, I was ment to do

document.getElementsByName("url")[0]

Haha, I never make that mistake... :oops:


Top
 Profile  
 
 Post subject: Re: javascript not working
PostPosted: Sun Aug 09, 2009 12:10 am 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
OK, well I don't get an error now but it still doesn't work. The url field in the form still reads...
Code:
<input type='hidden' name='url' value='' />


Top
 Profile  
 
 Post subject: Re: javascript not working
PostPosted: Sun Aug 09, 2009 2:36 am 
=^.^= Kitty =^.^=

Joined: Tue Mar 20, 2007 10:46 pm
Posts: 1821
Location: Sydney Australia
It wont change the code when you try to view source.

Just try do an

Code:
<script>
   var obj = doucment.getElementsByName("url")[0];
   alert(obj.value);
</script>


To make sure it works


Top
 Profile  
 
 Post subject: Re: javascript not working
PostPosted: Sun Aug 09, 2009 3:04 am 
Slave to the BB

Joined: Sat May 12, 2007 6:20 am
Posts: 3842
Location: Behind you!
Woo, it works! xD Thanks! Wow, I wonder if any of the others would have worked even the original one because I never checked to see if it worked I just always looked at the source.


Top
 Profile  
 
 Post subject: Re: javascript not working
PostPosted: Sun Aug 09, 2009 2:26 pm 
=^.^= Kitty =^.^=

Joined: Tue Mar 20, 2007 10:46 pm
Posts: 1821
Location: Sydney Australia
Hahahaha

I just can't believe I was so slow in this XD


Top
 Profile  
 
 Post subject: Re: javascript not working
PostPosted: Sun Aug 09, 2009 4:49 pm 
Carmack's Pimple

Joined: Tue Oct 10, 2006 9:39 am
Posts: 54
Location: Sedro-Woolley
:lol: You getting there


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC - 8 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group