Sunday, September 22, 2013

Re: How-to display a Javascript-Widget (e.g. from tripadvisor) in an GWT HTML Widget?

Thank you for your answer, but

if I enter the URL http://www.jscache.com/wejs?wtype=cdswritereviewlg&uniq=303&locationId=206597&lang=en_AU&border=true in browser I see the following document.write():
document.write( '<script src="http://www.tripadvisor.com/WidgetEmbed-cdswritereviewlg?amp;uniq=303&amp;border=true&amp;lang=en_AU&amp;locationId=206597"></script>' );

The domain www.jscache.com is from Tripadvisor (http://www.domainmetrics.de/domain/www.jscache.com) - maybe security reason - I don't know but it seems mandatory?

If I interpret your answer in a correct manner, I tested both:
ScriptInjector.fromUrl("http://www.jscache.com/wejs?wtype=cdswritereviewlg&amp;uniq=303&amp;locationId=206597&amp;lang=en_AU&amp;border=true").setWindow(ScriptInjector.TOP_WINDOW).inject();
and
ScriptInjector.fromUrl("http://www.tripadvisor.com/WidgetEmbed-cdswritereviewlg?amp;uniq=303&amp;border=true&amp;lang=en_AU&amp;locationId=206597").setWindow(ScriptInjector.TOP_WINDOW).inject();
but it is not working and only the text appears as described above.

If I try to enter the document.write()s script (<script src="http://www.tripadvisor.com.au/WidgetEmbed-cdswritereviewlg?uniq=303&locationId=206597&border=true&lang=en_AU"></script>) in the online-editor: http://www.w3schools.com/html/tryit.asp?filename=tryhtml_intro it is also now not working and I also see only the text.
So it seems, that the document.write() is mandatory.
How can I solve this problem or do you know a better way to integrate a Tripadisor widgets for reviews of hotels, created with this site: http://www.tripadvisor.de/Widgets ?


Am Sonntag, 22. September 2013 16:03:08 UTC+2 schrieb Thomas Broyer:


On Saturday, September 21, 2013 1:34:27 PM UTC+2, marian lux wrote:
I found something about "Script Injection" and tried the following code to add the script in my HTML page (on EntryPoint - method):

        Document doc = Document.get();
        ScriptElement script = doc.createScriptElement();
        script.setSrc("http://www.jscache.com/wejs?wtype=cdswritereviewlg&amp;uniq=303&amp;locationId=206597&amp;lang=en_AU&amp;border=true");
        script.setType("text/javascript");
        script.setLang("javascript");
        doc.getBody().appendChild(script);

It's a bit easier with GWT's ScriptInjector (just don't forget setWindow(TOP_WINDOW)).

and added the other code as String in an HTML-Widget.
But there is the same issue. Only the text:
"Review Grand Hotel Wien"
appears!

That script uses document.write() so it cannot be script-inserted. Try injecting the script it document.write()s though, it looks like it should be OK (just wouldn't benefit from "jscache.com", whatever it is)

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment