Solved

javascript conflict

Posted on 2008-10-28
3
275 Views
Last Modified: 2012-06-27
Hi Experts,

I am not familiar with Javascript. I am trying to get two separate scripts to work on one page. I think the initialization of each script is canceling the other out. Is it possible to stop the conflict with one call?

Thanks for your advise.
1st script init:
 
 
<script type="text/javascript">
 
function init() {
 
    blendImages('blendme');
}
 
window.onload = init;
 
</script>
 
 
 
 
 
2nd script init:
 
<script type="text/javascript">
	// <![CDATA[
	var myMenu;
	window.onload = function() {
		myMenu = new SDMenu("my_menu");
		myMenu.init();
	};
	// ]]>
	</script>

Open in new window

0
Comment
Question by:RowdyBurns
[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
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
HonorGod earned 500 total points
ID: 22820963
Yes, what you need to do is have a "wrapper" initialization function
that calls each initialization function.

Change function init() to look something like:

and remove this code...

        window.onload = function() {
                myMenu = new SDMenu("my_menu");
                myMenu.init();
        };
function init() {
  blendImages('blendme');
  myMenu = new SDMenu("my_menu");
  myMenu.init();
}

Open in new window

0
 

Author Closing Comment

by:RowdyBurns
ID: 31510698
Awesome! Working like a dream with your help! Thanks
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 22821853
You are very welcome.  Thanks for the grade & points.

Good luck & have a great day
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert Silverlight ERP To Angularjs,HTML5 3 62
Fix Form size HTML 16 31
Send form to asp server side 6 27
Bootstrap question 4 33
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. …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

726 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