Solved

Simple JS function usage

Posted on 2006-06-12
8
1,002 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 10

Expert Comment

by:0h4crying0utloud
ID: 16889622

I would start small with the working code and slowly add stuff to it....
0
 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
show form submit button based on jquery sum 5 31
HTML5 frame 5 26
CSS: Making Pure CSS read more boxes thinner 5 31
Optimize simple Javascript code to use no repetitions 12 32
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

821 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