Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » add bookmark/favorit using javascript
add bookmark/favorit using javascript [message #1115698] Tue, 24 September 2013 12:52 Go to next message
Flavio Donze is currently offline Flavio DonzeFriend
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 Go to previous messageGo to next message
Tim Buschtoens is currently offline Tim BuschtoensFriend
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/
Re: add bookmark/favorit using javascript [message #1117530 is a reply to message #1116419] Thu, 26 September 2013 14:42 Go to previous message
Flavio Donze is currently offline Flavio DonzeFriend
Messages: 211
Registered: July 2009
Location: Switzerland
Senior Member
Hi Tim

Thanks for your reply, since I'm still using RAP 1.4.2 I ended up using the Browser widget.

Thank you very much for your help!
Flavio


Prozessmanagement und Qualitätsmanagement Software QMS/IMS
https://www.scodi.ch

[Updated on: Thu, 26 September 2013 14:42]

Report message to a moderator

Previous Topic:SWTException in CoolBarManager on disposed CoolItem
Next Topic:Can I ensure that third party code uses my configured SettngStore
Goto Forum:
  


Current Time: Thu Apr 18 07:58:03 GMT 2024

Powered by FUDForum. Page generated in 0.01792 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top