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 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    simple?! problem with news scroller javascript

    Hiya,

    You'll have to excuse me, I'm just learning javascript and this is really bugging me now!

    I have a newscroller.js which contains amongst lots of other stuff the following:

    Code:
    function NewsScroller ()
    {
    	if (window.NewsScrollerInstance != null)
    		{
    		window.alert("Only one NewsScroller control is allowed on a page.");
    		return;
    		}
    	window.NewsScrollerInstance = this;
    	
    	this.LoadXML = NewsScroller_LoadXML;
    	this.AddNewsItem = NewsScroller_AddNewsItem;
    	this.Clear = NewsScroller_Clear;
    	this.StartScrolling = NewsScroller_StartScrolling;
    	this.StopScrolling = NewsScroller_StopScrolling;
    	this.Render = NewsScroller_Render;
    As you can see it defines NewsScroller_StartScrolling and NewsScroller_StopScrolling, which are the 2 lines I have to show you before I continue.


    Both of those are scripted like this:

    Code:
    function NewsScroller_StartScrolling ()
    {
    	if (this.itemCount > 0)
    		{
    		var sControlName = this.renderedControl;
    		if (sControlName == null)
    			{
    			window.alert ("You must render a control before you can start scrolling it.");
    			return;
    			}
    		var elmControl = document.getElementById(sControlName);
    		var elmItem0 = document.getElementById("floatingNews0");
    		if (this.itemCount > 1)
    			{
    			var elmItem1 = document.getElementById(sControlName + "1");
    			this.cySeparator = (elmItem1.offsetTop - elmItem0.offsetTop) - elmItem0.offsetHeight;
    			}
    		else
    			{
    			this.cySeparator = 0;
    			}
    		
    		if (this.ScrollTimerID == null)
    			this.ScrollTimerID = window.setInterval(NewsScroller_ScrollNews, this.scrollRate);
    		}
    }
    
    function NewsScroller_StopScrolling ()
    {
    	window.clearInterval(this.ScrollTimerID);
    	this.ScrollTimerID = null;
    }

    Now.. the problem i have is with my HTML page where I call this scroller applet. What happens now is that the whole thing scrolls all the way through without stopping. What I want is for onMouseOver to call the eventhandler "StopScrolling" and then on mouseout for it to null that by calling "startscrolling"

    My HTML code is this:

    Code:
    <script type="text/javascript">
    	var scrollerMain = new NewsScroller("main");
    </script>
    <xml id="xmlNews" src="xmlNews.xml"></xml>
    <div style="float: right; width: 200px; height: 250px;">
    	<script type="text/javascript">
    		scrollerMain.Render("floatingNews");
    		scrollerMain.LoadXML('xmlNews');
    		scrollerMain.StartScrolling ();
    		scrollerMain.onMouseOver = (StopScrolling);
    		scrollerMain.onMouseOut = (StartScrolling);
    	</script>
    </div>
    As you can see I've tried to stick the onMouseOver etc in there but I blatently dont know how to work it.

    Here is the helpful FAQ that came with this, taken from this page
    http://www.sharepointcustomization.c...er/default.htm

    Pause when hovering
    For this feature, you do not need to change the newsscroller.js script at all. In your page, after calling the Render method of the NewsScroller object, attach onmouseover and onmouseout event handlers to the element that contains your rendered NewsScroller object. In the handler for the onmouseover event, call the StopScrolling method, and in the handler for the onmouseout event, call the StartScrolling method.


    Sorry to make this a long post but I thought it was better to explain things clearly rather than just dump code on you and expect a quick answer.

    Thanks
    Hugh

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    As I read their explanation this should be it, but if it is it migth give some odd reactions.

    <script type="text/javascript">
    var scrollerMain = new NewsScroller("main");
    </script>
    <xml id="xmlNews" src="xmlNews.xml"></xml>
    <div style="float: right; width: 200px; height: 250px;" onmouseout=" scrollerMain.StartScrolling ();" onmouseover="scrollerMain.StopScrolling();">
    <script type="text/javascript">
    scrollerMain.Render("floatingNews");
    scrollerMain.LoadXML('xmlNews');
    scrollerMain.StartScrolling ();
    </script>
    </div>

  • #3
    New Coder
    Join Date
    Apr 2005
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    legend!

    Thankyou

  • #4
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to update data in XML file using VB.NET?

    Hi guys ..

    I'm just the beginner, now i've got some problem in my task. I'm also using the newscroller Javascript as same as the above

    I want to update my XML file (News.xml) using VB.NET code behind. I have managed to create XML like this :-



    <NewDataSet>
    <Item>
    <Text> testing one </Text>
    </Item>
    </NewDataSet>


    .. and from this XML file, I want to load it into the newscroller Javascript.
    The problem is, the Javascript code just can load XML data field like below only --->



    <xml id="xmlNews">
    <Items>
    <Item>
    <Text> testing two </Text>
    </Item>
    <Items>
    </xml>



    and if i update the XML file, it will store 'outside' of the <xml id="xmlNews'>.



    <NewDataSet>

    <xml id="xmlNews">
    <Items>
    <Item>
    <Text> testing two </Text>
    </Item>
    <Items>
    </xml>

    <Item>
    <Text> testing one </Text>
    </Item>
    </NewDataSet>


    ..as the result, the newscroller Javascript will not load the updated values (testing one) above.

    can somebody help me please ..?
    if you guys do not follow the problems, later i will post the VB.Net Code to create the dataset of the XML..

    thank you


  •  

    Posting Permissions

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