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.
Results 1 to 7 of 7
  1. #1
    Junsee
    Guest

    I wonder if I could get a hand here

    I am having trouble here with copy and paste JavaScript.
    I wonder if someone could give me a hand...


    Code:
    	<script language="JavaScript"> 
        (function($){
    		window.onload=function(){ 
    			$(".jCarouselLite").jCarouselLite({
    				auto: 2000,
    				speed: 2700,
    				circular: true,
    				visible: 1,
    				mouseWheel: true,
    				scroll: 1
    			});
    	
    		}
        })(jQuery);
    	</script>
    and I need to insert this into it

    Code:
    			function showlargeimage(imgshow) {
    				document.getElementById('image').src=imgshow;
    				document.getElementById('image').style.display='block';
    			}
    I am useless at javascript
    Thank you in advance for any help
    James

  • #2
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    878
    Thanks
    0
    Thanked 114 Times in 113 Posts
    putting a window.load inside a (function($){ ?

    The only difference between them is:
    function($){[/B] is called when the documents source code is loaded.
    window.onload is called when all contebt is loaded in.

    Waiting to define the window.unload , until the source code is loaded makes no sense, as it will run at the same time no matter when it is defined.

    I wil suggest that you choose between:
    Code:
    <script language="JavaScript"> 
    		window.onload=function(){ 
    			$(".jCarouselLite").jCarouselLite({
    				auto: 2000,
    				speed: 2700,
    				circular: true,
    				visible: 1,
    				mouseWheel: true,
    				scroll: 1
    			});
    	
    		}
    	</script>
    or
    Code:
    <script language="JavaScript"> 
        (function($){
    			$(".jCarouselLite").jCarouselLite({
    				auto: 2000,
    				speed: 2700,
    				circular: true,
    				visible: 1,
    				mouseWheel: true,
    				scroll: 1
    			});
    	
        })(jQuery);
    	</script>
    And then the insertion:
    do you want to delay the definition of the function, - or do you want to execute it?

    Case 1 - delay definition:
    Code:
    <script language="JavaScript"> 
        (function($){
    			$(".jCarouselLite").jCarouselLite({
    				auto: 2000,
    				speed: 2700,
    				circular: true,
    				visible: 1,
    				mouseWheel: true,
    				scroll: 1
    			});
    	
                            showlargeimage = function(imgshow) {
    				document.getElementById('image').src=imgshow;
    				document.getElementById('image').style.display='block';
    			}
        })(jQuery);
    	</script>
    ( notice then change from function showlargeimage(creating the function) to showlargeimage = function(given the function a handle). )

    Case 2 - execute the function:
    Code:
    <script language="JavaScript"> 
        (function($){
    			$(".jCarouselLite").jCarouselLite({
    				auto: 2000,
    				speed: 2700,
    				circular: true,
    				visible: 1,
    				mouseWheel: true,
    				scroll: 1
    			});
    	      showlargeimage('Thepicture.png');
        })(jQuery);
    			function showlargeimage(imgshow) {
    				document.getElementById('image').src=imgshow;
    				document.getElementById('image').style.display='block';
    			}
    	</script>

  • Users who have thanked Lerura for this post:


  • #3
    Junsee
    Guest
    Thanks very much

    Javascript has never made much sense to me. The "jCarouselLite" is an onload function... but the ImageShow is not (A delay Function!).

    I find that asking java to onload jCarouselLite and just load when needed the ImageShow causes no ends of errors. For the sake of getting java to work for me I had, in the past, to onload everything.

    Thanks and I'll get back in a bit

  • #4
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    Quote Originally Posted by iBall View Post
    <offTopic style="clarification">



    At least get the name of the language correct.

    You are using JavaScript (or in this case a JavaScript library, Jquery)

    Java and JavaScript are 2 totally different languages.

    Java is to JavaScript as Ham is to Hamptster


    </offTopic>

    actually its jQuery not Jquery, please try and get the capitalization correct (in English capitalisation is correct of course)
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #5
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    Quote Originally Posted by iBall View Post
    <offTopic style="clarification">



    At least get the name of the language correct.

    You are using JavaScript (or in this case a JavaScript library, Jquery)

    Java and JavaScript are 2 totally different languages.

    Java is to JavaScript as Ham is to Hamptster


    </offTopic>
    Please try and correctly spell the name of rodents belonging to the subfamily Cricetinae
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,731
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    Quote Originally Posted by firepages View Post
    Please try and correctly spell the name of rodents belonging to the subfamily Cricetinae
    He could not spell hamster when he was bullant, either.

    Help with buttons

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #7
    Junsee
    Guest
    Thank you all for the help...
    I managed to get it working ... for the future generations that perhaps need the help aswell I used...

    Code:
    <script language="JavaScript"> 
    	window.onload=function(){ 
    		$(".jCarouselLite").jCarouselLite({
    			auto: 2000,
    			speed: 2700,
    			circular: true,
    			visible: 1,
    			mouseWheel: true,
    			scroll: 1
    		});
    
    	}
    	function showlargeimage(imgshow) {
    		document.getElementById('image').src=imgshow;
    		document.getElementById('image').style.display='block';
    	}
    </script>
    iBall was it really worth the flaming?

    Thank you again
    James


  •  

    Posting Permissions

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