Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    F1p
    F1p is offline
    New Coder
    Join Date
    Sep 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Possible Conflict??

    Heya there,

    I have been trying to run two Javascripts within the same page.

    The first is the Drop down menu Javascript, the second is the Picture Viewer (Click an image and it opens)


    Here is a copy of the webpage (the active version has been modified to reduce confusion for users)

    http://f1p.co.uk/saved%20pages/picture1.html



    I have tried a noconflict, but it didn't seem to work.
    As you can see, the Picture viewer works fine, but the drop down menu seems to be in conflict.

    Any help please?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    This topic has been covered a zillion times in this forum.

    There are two reasons why two scripts can conflict and not work tigether;-

    a) Duplication of function and/or variable names in the two scripts- the second will over-write the first.

    b) Multiple onload statements. See:-

    http://www.javascriptkit.com/javatut...iplejava.shtml
    http://www.dyn-web.com/tutorials/combine.php

    Or to resolve you can simply fire a set of functions when the page loads.
    Code:
    <script type="text/javascript">
    window.onload = function() {
    functionOne();
    functionTwo();
    }
    </script>

    "From now on, ending a sentence with a preposition is something up with which I will not put." - Sir Winston Churchill, British politician (1874 - 1965)

  • #3
    F1p
    F1p is offline
    New Coder
    Join Date
    Sep 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have no idea where to put it, that's the problem!
    Would you possibly be able to do it?

    Regards,

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    <meta name="author" content="P A Thomson">

    Try P.A.Thomson. But I suggest you fix the errors in your markup first.
    See http://validator.w3.org/

  • #5
    F1p
    F1p is offline
    New Coder
    Join Date
    Sep 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am P.A.Thomson.....


    I was hoping someone could show me an implemented and working version.
    Last edited by F1p; 09-02-2010 at 08:37 PM.

  • #6
    F1p
    F1p is offline
    New Coder
    Join Date
    Sep 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh, an example of the working Menu can be found on the site index:

    http://www.f1p.co.uk/index.html

  • #7
    F1p
    F1p is offline
    New Coder
    Join Date
    Sep 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    This topic has been covered a zillion times in this forum.

    There are two reasons why two scripts can conflict and not work together;-

    a) Duplication of function and/or variable names in the two scripts- the second will over-write the first.

    b) Multiple onload statements. See:-

    http://www.javascriptkit.com/javatut...iplejava.shtml
    http://www.dyn-web.com/tutorials/combine.php

    Or to resolve you can simply fire a set of functions when the page loads.
    Code:
    <script type="text/javascript">
    window.onload = function() {
    functionOne();
    functionTwo();
    }
    </script>

    "From now on, ending a sentence with a preposition is something up with which I will not put." - Sir Winston Churchill, British politician (1874 - 1965)
    Thanks for the help, i seem to be having problems still.

  • #8
    F1p
    F1p is offline
    New Coder
    Join Date
    Sep 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [QUOTE=Philip M;989683]This topic has been covered a zillion times in this forum.

    There are two reasons why two scripts can conflict and not work tigether;-

    a) Duplication of function and/or variable names in the two scripts- the second will over-write the first.

    b) Multiple onload statements. See:-

    http://www.javascriptkit.com/javatut...iplejava.shtml
    http://www.dyn-web.com/tutorials/combine.php

    Or to resolve you can simply fire a set of functions when the page loads.
    Code:
    <script type="text/javascript">
    window.onload = function() {
    functionOne();
    functionTwo();
    }
    </script>

    What name should be entered in "functionOne and functionTwo?

    Is it the location of the Javascript?
    eg.

    Code:
    <script type="text/javascript" src="http://f1p.co.uk/pictureplayer/js/prototype.js"></script>
    Function one called "prototype"?

  • #9
    F1p
    F1p is offline
    New Coder
    Join Date
    Sep 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay,

    Looking even closer!

    There are two reasons why two scripts can conflict and not work together;-

    a) Duplication of function and/or variable names in the two scripts- the second will over-write the first.
    This seems to be the problem i think...
    I have no onload tags to make them conflict.

  • #10
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by F1p View Post
    Okay,

    Looking even closer!

    This seems to be the problem i think...
    I have no onload tags to make them conflict.
    Yes, check carefully, including variables such as for i = 0 and so on.

  • #11
    F1p
    F1p is offline
    New Coder
    Join Date
    Sep 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    Yes, check carefully, including variables such as for i = 0 and so on.
    If i find any the same, what would be best to do?

  • #12
    F1p
    F1p is offline
    New Coder
    Join Date
    Sep 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have found:

    Code:
    var result
    in two different Javascripts, is this a problem?

  • #13
    F1p
    F1p is offline
    New Coder
    Join Date
    Sep 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Okay, i have found the same var, "var result" in two Javascripts i wish to use.


    Javascript One (Original):

    Code:
    var result=window.location.search.match(new RegExp(headerclass+"=((\\d+)(,(\\d+))*)", "i")) //check for 
    
    "?headerclass=2,3,4" in URL
    		if (result!=null)
    			result=RegExp.$1.split(',')
    		return result //returns null, [index], or [index1,index2,etc], where index are the desired selected header 
    
    indices
    	},
    Should i change "var result" to "var resultA" to stop confliction?
    And should i then also change the following results to "resultA" ?


    Code:
    var resultA=window.location.search.match(new RegExp(headerclass+"=((\\d+)(,(\\d+))*)", "i")) //check for 
    
    "?headerclass=2,3,4" in URL
    		if (resultA!=null)
    			resultA=RegExp.$1.split(',')
    		return resultA //returns null, [index], or [index1,index2,etc], where index are the desired selected header 
    
    indices
    	},

  • #14
    F1p
    F1p is offline
    New Coder
    Join Date
    Sep 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried this and it didn't seem to help at all...

  • #15
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,910
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Keep looking for duplicates! You have dealt with "result" correctly although make sure that it is not referenced elsewhere in the script.


  •  
    Page 1 of 2 12 LastLast

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •