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: iframe link to open Safari




On Jun 14, 2005, at 11:20 AM, Steve Weyer wrote:

we're getting close!

if (parent.window.widget) {parent.widget.openURL...}
or
if (parent.widget) {parent.widget.openURL...}

appears to work fine -- if the iframe is a local file, i.e., inside the widget. thanks.

however, if the iframe file is remote, it fails (it doesn't open Safari; linked page opens in the widget itself).


here's an example I concocted: http://home.comcast.net/~saweyer/test/IframeLinkTest.wdgt.zip

when it opens, it uses the local file (IframeContent.html) -- the two embedded links open the Apple web site in Safari. so far so good.

if you then select Remote from menu, it updates to the remote version of the file -- filename has "2" suffix;
and table label omits "loc" prefix for iframe heading; otherwise, everything else, javascript & links are identical.
links in iframe fail to open Safari but display inside the widget.


suggestions?


Steve—

I see what you're doing. It's not going to work for security reasons— I modified your code so that the network page tries to call _any_ function in the parent iframe—Console had this text as a result:

2005-06-14 11:39:45.103 DashboardClient[997] (com.apple.widget.iframelinktest) : Unsafe JavaScript attempt to access frame with URL file:///Volumes/cpw/Downloads/ IframeLinkTest.wdgt/IframeLinkTest.html from frame with URL http:// cpw/~cpw/IframeContentPage2.html. Domains must match.

I don't think that it will ever work for you, no matter what tricks you pull. That's OK though... The thing about loading an iframe from the web is that, if someone's not on the web, the experience can be jarring.

Instead, I'd suggest that you fetch information using the XMLHttpRequest object within your widget's JavaScript and then act on it within the widget's JavaScript. That way, you can handle different operating conditions and work with your UI asynchronously, locally. You may have heard the term "AJAX" floating around the web— Asynchronous JavaScript and XMLHttpRequest—it's basically a technique and it's what I'm recommending you use here. It's pretty simple to use and it solves your problem nicely. _______________________________________________
Do not post admin requests to the list. They will be ignored.
Dashboard-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/dashboard-dev/email@hidden


This email sent to email@hidden
References: 
 >Re: iframe link to open Safari (From: Steve Weyer <email@hidden>)



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.