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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post

    javascript crashing browser..

    when I call some of my functions in JS, they work with no problems.... but then it seems to crash the entire browser when I try to do something else.

    Is there a cache or is it possible that some JS variables are being remembered??

    I was just wondering if there was a way to clear the cache maybe?? Its really confusing me why its doing this!!

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    What was that "something else" that you did and caused the browser to crash?

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    well, there is a lot of things happening... but it seems to be when I call a function to check if text is highlighted.. I then say, listen to what key was pressed...

    if the user tries to delete the selection, it does the following

    Code:
    alert("you cant delete that");
    iView.event.cancelBubble = true;
    iView.event.returnValue = false;
    it then crashes if you try to type or do anything else....

    is there a buffer or something?

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    Probably best if I give you an example!!

    http://www.recaf.net/tmp/howard/editor.htm

    highlight the first three lines (from Dear.... to .... is)

    then press the backspace key....

    it will alert saying you cant delete that...

    then put your cursor infront of the first word "Dear"

    and press any key..

    it then crashes......


  • #5
    Regular Coder
    Join Date
    Nov 2002
    Location
    Manchester, UK
    Posts
    533
    Thanks
    4
    Thanked 1 Time in 1 Post
    I found the problem - just need help to solve it now!!
    here's the function causing problems...

    Code:
    		function lookLeft()
    		{
    			var code = iView.document.selection;
    			var tmp = code.createRange();
    			tmp.collapse();
    			tmp.move("character",-1);
    			tmp.expand("character");
    			
    			if (!tmp.collapse())
    			{
    				//we cannot move left as there are no characters there! (possible the beginning of the page)
    				return "";
    			}
    			else
    			{
    				return tmp.text;
    			}
    			
    		}
    the code is supposed to get the character to the left of the cursor position... but if there is no character to the left -ie the cursor is at the beginning of the sentance, then it should return a value of "" (blank)... otherwise return a value of the character.

    I need a way of saying - if moving one char back is not possible, then return ""....

    but it doesnt work!!


  •  

    Posting Permissions

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