Solved

Simple JS function usage

Posted on 2006-06-12
8
1,000 Views
Last Modified: 2012-07-09
Hey all,
 Simple JS.  I can't seem to get into the OAS_RICH function.  I can hit the AD function and the conditional but it doesn't call the OAS_NORMAL function.... am I doing something wrong ?


<SCRIPT LANGUAGE=JavaScript>
<!--
version = 11;
function OAS_NORMAL(pos) {
  document.write('test normal');
}
function OAS_RICH(pos) {
    document.write('test rich');
 }
//-->
</SCRIPT>

<SCRIPT LANGUAGE=JavaScript>
<!--
function AD(pos) {
   
  if (version >= 11)
    OAS_RICH(pos);
  else
    OAS_NORMAL(pos);
}
//-->
</SCRIPT>
0
Comment
Question by:rpong
8 Comments
 
LVL 10

Accepted Solution

by:
0h4crying0utloud earned 500 total points
ID: 16889564

I replace your code w/ alerts works in IE6 and FF...


<SCRIPT LANGUAGE=JavaScript>
<!--
version = 11;
function OAS_NORMAL(pos) {
  alert('test normal');
}
function OAS_RICH(pos) {
    alert('test rich');
 }
//-->
</SCRIPT>

<SCRIPT LANGUAGE=JavaScript>
<!--
function AD(pos) {
   
  if (version >= 11)
    OAS_RICH(pos);
  else
    OAS_NORMAL(pos);
}

AD('test');
//-->

</SCRIPT>
0
 
LVL 10

Expert Comment

by:0h4crying0utloud
ID: 16889572


So I'm just not sure what it could be...
0
 

Author Comment

by:rpong
ID: 16889601
darn, I did the same thing and I couldn't get into the function.  

 Aparently something else in my code is preventing it from being called.
0
 
LVL 10

Expert Comment

by:0h4crying0utloud
ID: 16889622

I would start small with the working code and slowly add stuff to it....
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 23

Expert Comment

by:basicinstinct
ID: 16889632
The answer is 'YES' you are doing something wrong - post more code

here's a test page that shows all of your functions firing:
<html>
<head>
<SCRIPT LANGUAGE=JavaScript>
<!--
version = 11;
function OAS_NORMAL(pos) {
  document.write('test normal');
}
function OAS_RICH(pos) {
    document.write('test rich');
 }
//-->
</SCRIPT>

<SCRIPT LANGUAGE=JavaScript>
<!--
function AD(pos) {
   
  if (version >= 11)
    OAS_RICH(pos);
  else
    OAS_NORMAL(pos);
}
//-->
</SCRIPT>
</head>
<body>
<form name="test">
      <input type="button" value="OAS_NORMAL" onclick="OAS_NORMAL(1);"/><br/>
      <input type="button" value="OAS_RICH" onclick="OAS_RICH(1);"/><br/>
      <input type="button" value="AD" onclick="AD(1);"/>
</form>
</body>
</html>
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 16889682
The OAS_NORMAL() is called only for version value 10 and lower.
And you have to be aware that document.write() CAN destroy the previous scripts on the page.
To see the dynamic content of the page use devic's PageSpy: http:/M_1344026.html
0
 

Author Comment

by:rpong
ID: 16889705
ok ok ok, I'll post more code, I have to format it though
0
 

Expert Comment

by:sofiakhatoon
ID: 38168213
The issue here is the use of Language attribute in Javascript. It should be

 script type='text\Javascript'
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now