add bookmark/favorit using javascript [message #1115698] |
Tue, 24 September 2013 12:52 |
Flavio Donze Messages: 211 Registered: July 2009 Location: Switzerland |
Senior Member |
|
|
Hello
I have an application where I open RAP editors containing a browser with certain URL.
Now I would like to provide a handler which adds the current URL to the browsers bookmakrs/favorits.
I only want to provide this function for IE.
This is what I came up with:
String script = "window.external.AddFavorite(\"" + url + "\", \"" + label + "\");";
org.eclipse.rwt.internal.widgets.JSExecutor.executeJS(script);
If I execute this nothing happens, no warning, exception or anything.
Executing javascript else works, for example I have this zoom function:
String script = "if(window.parent.document.body.style.zoom!=0) window.parent.document.body.style.zoom*=0.8; else window.parent.document.body.style.zoom=0.8;";
org.eclipse.rwt.internal.widgets.JSExecutor.executeJS(script);
I also tested the plain "window.external.AddFavorite..." outside of RAP, which also works, Favorit Dialog is opened.
Any idea on how I can solve this? Am I executing the script wrong?
greets and thanks for any help
Flavio
Prozessmanagement und Qualitätsmanagement Software QMS/IMS
https://www.scodi.ch
[Updated on: Tue, 24 September 2013 12:53] Report message to a moderator
|
|
|
Re: add bookmark/favorit using javascript [message #1116419 is a reply to message #1115698] |
Wed, 25 September 2013 12:08 |
Tim Buschtoens Messages: 396 Registered: July 2009 |
Senior Member |
|
|
Hi.
My guess is this:
"For security reasons, the AddFavorite method must be called as a
response to a user-initiated action, such a mouse click. If called from
a different context, such as the onload event of the body element, the
AddFavorite method fails silently." [1]
There are may ways to work around this. For example you could use a
Browser widget to create a button or link that does this on the client.
(The button would probably not look like other RAP buttons.) Other ways
would be to use ClientScripting, the MARKUP_ENABLED feature or a custom
widget.
Greetings,
Tim
[1] http://msdn.microsoft.com/en-us/library/ms535926%28v=vs.85%29.aspx
Am 24.09.2013 14:52, schrieb Flavio Donze:
> Hello
>
> I have an application where I open RAP editors containing a browser with
> certain URL.
> Now I would like to provide a handler which adds the current URL to the
> browsers bookmakrs/favorits.
> I only want to provide this function for IE.
> This is what I came up with:
>
>
> String script = "window.external.AddFavorite(\"" + url + "\", \"" +
> label + "\");";
> org.eclipse.rwt.internal.widgets.JSExecutor.executeJS(script);
>
>
> If I execute this nothing happens, no warning, exception or anything.
>
> Executing javascript else works, for example I have this zoom function:
>
>
> String script = "if(window.parent.document.body.style.zoom!=0)
> window.parent.document.body.style.zoom*=0.8; else
> window.parent.document.body.style.zoom=0.8;"
> org.eclipse.rwt.internal.widgets.JSExecutor.executeJS(script);
>
>
> I also tested the plain "window.external.AddFavorite..." outside of RAP,
> which also works, Favorit Dialog is opened.
> Any idea on how I can solve this? Am I executing the script wrong?
>
> greets and thanks for any help
> Flavio
--
Tim Buschtöns
Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/
Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03396 seconds