Solved

Simple JS function usage

Posted on 2006-06-12
8
999 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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 …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

746 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

12 Experts available now in Live!

Get 1:1 Help Now