SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Strange security exception in FF but script works

    Im tinkering with a VERY old script I wrote YEARS ago that allows someone to "just keep typing" when doing a 3 field phone number entry .... Ive made it work but FF is giving me the STRANGEST security exception Ive ever seen.. I Googled it but only found stuff relating to Frames and different url type things (script on one, page on another) ..... none of these apply to this as both test page and script are in my local server on my machine.... anyways here the exception copied out of FF:

    Code:
    Error: [Exception... "'Permission denied to get property XULElement.selectedIndex' when calling method: [nsIAutoCompletePopup::selectedIndex]"  nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)"  location: "JS frame :: http://localhost:8080/scripts/patAllen.js :: checkKeyPress :: line 7"  data: no]
    Source File: http://localhost:8080/scripts/patAllen.js
    Line: 7
    and heres the function in its rawest form (I broke everything down to try and flush out he problem)

    Code:
    function checkKeyPress(box, size)	{
    	if (box.value.length == size && box.value.length != 4)	{
    		var currentBox = box.name;
    		var currentNum = parseInt(currentBox.substring(currentBox.length - 1, currentBox.length));
    		currentNum++;
    		var nextBox = currentBox.substring(0, currentBox.length -1) + currentNum;
    		document.getElementById(nextBox).focus();
    		}
    	}
    and the calling code:

    Code:
    <p><input type='text' name='home_phone_1' id='home_phone_1' size='3' maxlength='3' onkeypress='checkKeyPress(this, 3);' /> - 
    <input type='text' name='home_phone_2' id='home_phone_2' size='3' maxlength='3' onkeypress='checkKeyPress(this, 3);' /> - 
    <input type='text' name='home_phone_3' id='home_phone_3' size='4' maxlength='4' onkeypress='checkKeyPress(this, 4);' /> Home Phone </p>
    NOw before anyone goes thru that error and sees things that arent there heres what Im NOT doing:

    NO FRAMES
    NO POPUPS
    NO selectedIndex (they are text boxes)

    The only thing I could think of what the function was interferring with FF's own "autocomplete" functions ..... because of this : nsIAutoCompletePopup

    Anyone seen this before or see something Im doing that may be construed as a security exception ...... as I said the code is at a hacker level now because I was trying to figure which bit of functionality was blowing this.... I did also want to mention that I was getting the exact same security exception when I was doing nothing more than an alert on the box.name

  2. #2
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Someone has to have seen this before .... 7stud, VGarcia ... anybody

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like textboxes in Mozilla are vain: once they are the center of attention, they don't like the attention to be shifted away. Try the following script: clicking on the textbox causes the same error, however clicking on the <div> doesn't--even though they call the same function. Then, try commenting out the alert(), and uncommenting out the line after it--when you keep the attention on the textbox, then there is no error. The third line shifts attention away from the textbox using focus() instead of alert() and once again you get the error when clicking on the textbox but not the <div>.

    Code:
    <html>
    <title></title>
    <script type="text/javascript" language="javascript">
    <!-- Hide from browsers without javascript
    
    function g()
    {
    	x(); 
    }
    
    function x()
    {
    
    	alert("x");
    	//document.getElementById("tb0").focus();
    	//document.getElementById("tb1").focus();
    }
    
    
    // End hiding -->
    </script>
    </head>
    <body>
    
    <div onclick="g()">click me</div>
    
    <div>-----</div>
    
    <form name="f" method="post" action="">
    	<input type="text" id="tb0" onclick="g()" value="click me"/>
    	<input type="text" id="tb1" />
    </form>
    
    </body>
    </html>


Bookmarks

Posting Permissions

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