Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Simple JS function usage

Posted on 2006-06-12
8
Medium Priority
?
1,010 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 10

Accepted Solution

by:
0h4crying0utloud earned 2000 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

636 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