Solved

Simple JS function usage

Posted on 2006-06-12
8
1,008 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 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

717 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