Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Safari and object dragging



Matthew,

On Friday, October 10, 2003, at 10:00 PM, email@hidden wrote:

I found a true Safari bug, and will be filing a formal Apple bug report.

I don't mean to sound presumptuous, but you make it sound as though you're looking for problems with Safari, not trying to resolve problems that you find.


Here's the code that works in all browsers except Safari:
    <script language="javascript" type="text/javascript"><!--
      function TEST() {
        for (var args = TEST.arguments, i = args.length;  i--;  )
          alert("args[i=" + i + "]=\"" + args[i] + "\"");
      }
      TEST("A", "B", "C");
      -->
    </script>


When I copied this code and tested it, as I suspected, it didn't work. There are a couple of things I changed to get it working though. First, the syntax of the for loop isn't correct. There are only 2 parameters, not the necessary 3. Next, I don't know if this is a syntactical error or not, but Safari didn't like the semi-colon after the i--. Now that I say that, it's possible that you have the arguments out of order and are leaving the last one blank.


I always prefer to use single quotes in my JavaScript strings, using double quotes inside the singles, where an actual quote should appear. The last thing I noticed was that the length is one-based, while array elements are zero-based. So to get the proper output you'd want to set i=args.length-1. Here's the code that I used to do get this all to work:

<script language="javascript" type="text/javascript">
<!--
	function TEST()
	{
		for(args=TEST.arguments,i=args.length-1; i>=0; i--)
		{
			alert('args[i=' + i + ']="' + args[i] + '"');
		}
	}
	TEST('A', 'B', 'C');
-->
</script>

Thanks for the help,

While I haven't looked close enough to see how Panic (http://www.panic.com) did it, compared to what you're trying to do with <div> tags, their implementation of drag and drop is, IMHO, the best thing I've seen. The code is very clean, and seems easy enough to understand. Plus, it doesn't require a plugin, which is a bonus in my opinion. Also, I haven't tested it in all browsers, but the Mac and Win browsers I have tested work great.


macmec ~ email@hidden
This message was sent from a Macintosh computer.  Epitome of creativity.
_______________________________________________
web-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/web-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.