ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • When you purchase through links on our site, we may earn an affiliate commission. Read more here.

Javascript



  Not a Clio
IE doesn't like this bit of code but I don't know why:

<script>
reg = document.getElementById('register');
if(userlinks.innerHTML.match(/as/))
{
reg.innerHTML = "";
}
</script>


It says: 'reg' is null or not an object
About this: reg.innerHTML = "";

I know IE is fussy, I don't get this in firefox.

Any ideas?
 
  Not a Clio
It's not code i have written and i don't have much of a clue with this stuff.

here's the full code:

<script>
/*
Make guests view rules before registering
by gamefreak11
version 2.0
Original code by Webworldx
*/
var q = document.getElementsByTagName('A')
for (i=0;i<q.length;i++){
if (q.href.indexOf("act=Reg&CODE=00") != -1){
q.href="http://ukrabbitsandcavies.info/index.php?act=boardrules"
}}
</script>
<script>
reg = document.getElementById('register');
if(userlinks.innerHTML.match(/as/))
{
reg.innerHTML = "";
}
</script>
 
You are trying to update an element on your HTML page that has basically not been created yet. For example, your page currently looks like this

Start Page

...
...
...

Update the element "register" to a new value

..
..
..

Create the element "register"

...
...
...

End Page


You need to 1st createt the HTML element and then run your code

here is what I mean


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>


</head>

<body>

<span id="register"></span>

<script>
var reg = document.getElementById('register');
reg.innerHTML = "I have updated the register HTML elements inner HTML";
</script>

</body>
</html>
 
  Astra 1.9cdti XP
Yup...or just create a function with that method and call it when you need i.e. in the onLoad of the body element!
 


Top