Can't add external script into gwt widget - gwt

I am trying to add google gadget into FlowPanel(or HTMLPanel), but after a host page is loaded it navigates away from my page and shows gadget in a new page, if i click browser's back button it loads host page and again navigates away to new page to show the gadget.
Here is the code:
String code="here_goes_scrip_tag_for_gadget";
flowPanel.add(new HTML(SafeHtmlUtils.fromTrustedString(code)));
What am i doing wrong, please help.
UPDATE
The above code to load script was wrong, i've modified it as following:
FlowPanel gadgetContainer = new FlowPanel();
Element script = Document.get().createScriptElement();
script.setAttribute("type", "text/javascript");
script.setAttribute("src", "http://www.gmodules.com/ig/ifr?url=http://digg.com/goog/ig.xml&up_user=&up_thumbnail=1&up_filter=0&up_num=5&up_type=popular&up_refresh=0&up_tab=0&up_offset=0&up_pagination=0&up_business=true&up_entertainment=true&up_gaming=true&up_lifestyle=true&up_offbeat=true&up_politics=true&up_science=true&up_sports=true&up_technology=true&up_world_news=true&synd=open&w=320&h=200&title=Digg&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js");
gadgetContainer.getElement().appendChild(script);
But it still doesn't work.

For solving this problem in general, check out the com.google.gwt.core.client.ScriptInjector class - it has two methods that allow you to inject scripts into the page in a cross browser way. The way you are attempting to inject the script content won't work cross browser.
Looking specifically at your gadget case, I'm guessing that the script you are loading has code in it to prevent it from being loaded into another page. Have you tried to use a plain html page that references that script tag? If the same thing happens, see if you can see where in the script file the page reassigns window.location.

Related

New Relic Data gives Wrong page views URL after New Relic script added via DTM

We have added a new relic script via DTM,
and New Relic Data shows wrong Page URL, it shows Page views as DTM URL, not actual page views,
this happening because DTM will compile all scripts and executes the script with in a iFrame. so New Relic is considering iframe url as request URL.
any one have idea how to fix this using DTM ?
Thanks
From the documentation, there are 4 types of Javascript / 3rd Party Tag containers.
It sounds like you chose Non-Sequential HTML container type, which appends a DTM hosted iframe to the page, with your code in it. To append your code to the parent page, you must change the tag type to either Sequential HTML, or convert the tag to pure javascript and use Sequential Javascript or Non-Sequential Javascript type.
Side note: make sure to read the document page I provided above to ensure the type you choose is compatible with when you have it set to output (top of page, bottom of page, dom ready, window load)

Using Adobe Test-and-Target, how do I avoid seeing the first page before the redirect kicks in?

I've got an A/B Test set up in Adobe Test-and-Target. The idea is that 50% of the time, visitors to a certain page should be redirected to a different page instead. It is working correctly, in that half of users are sent to the new page.
However, sometimes the entire original page is loaded before the redirect happens. I put the mbox in the head tag of the page, which I thought would ensure the redirect happened before any HTML was displayed to the user, but that's not happening.
How can I create a seamless result for the user, where the redirected users only see the new page loading, and never see the original page?
For our site, the <script src="http://maur.imageg.net/js/mbox.js" ></script>is at the very end of the head tag and works fine.
Your mbox.js should be as close to the top as possible and then your inline mbox should be defined preferably right after the tag. This way the request is made before the content starts to render, and the redirect kicks in before the guest even sees the page.
Avoid using anything post DOM related for example jQuery's:
document.ready( function{});
If you paste your code you're using for the A/B - we be able to review & respond accordingly.
However pure Javascript and pure CSS should execute seamlessly.
You can use CSS first to not show anything
<style>
body {display:none!important}
</style>
Then use JavaScript to redirect the page to new page.

How to find if web page got appended using chrome extension

I am new to chrome extension and I am trying to find whether page content got appended.
For E.g. in Facebook, we can see the content will appended automatically when the user scroll down the page.
I have the following code in background.js
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
alert("page is appending....");
});
The above code is expected to fire when the page got updated. But, I am seeing that it is getting called only for few times. Not always.
Or Am I making any mistake here ?
My requirement is, whenever the web page appended in facebook, I have to do get the page content and obtain few string from the same.
Thanks in advance.
Your onUpdated event is in the chrome.tabs namespace on purpose, it listens the updates of tab's general attributes like: the tab pinned, the favicon changed, the URL changed, see the documentation (also check the update() method). So this way is not workable. Instead listen the DOM tree change with DOMSubtreeModified event or MutationObserver.

Dirrect way to get content of current open page into main.js file in FireFox add-on sdk

I have one problem with add-on Firefox sdk. I'm searching a way to get content of current working page into main.js file. The application is based on widget that open popup when is clicked. I have one idea. To inject content script into open with sdk/page-worker and this content script using port API (self.port.emit) to trigger event and pass document.body.innerHTML. Like this:
self.port.emit("getCurrentPageHtml", document.body.innerHTML);
And into main.js file:
popupName.port.on("getCurrentPageHtml", function (receivedHtml) {
// handle received html
});
But will be very good idea if there is some direct API and avoid this communication.
I would appreciate any advice and tips.
Best regards.
I answer my own question for the second time today. Pity. Apparently there is no direct way to do this. So we can listen for panel event with popuVar.port.on. After this we can use:
// must be required tab api
// https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/tabs
tabs.activeTab.url
and use page-worker on this url https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/page-worker. After this content script of this page worker will trigger event to get html of page. Another option is just made request to url of current page.

Facebook Send button does not show up on Gwt popup panel?

I'm trying to get Facebook send or like button display on GWT popup panel and I am not successful. When inspecting the generated HTML, facebook HTML button looks properly inserted into but it just does not show up. Save Facebook button works well in html page (not on GWT panel).
Have you ever had success in displaying Facebook Send or Like or Share button in GWT? I know I ca implement FB Like button myself using API or other libraries. But I do it need that. I need standard Facebook Send button to be used in my GWT application.
Please advise me if you have experience and were successful.
Thank you very much!
I had a similar problem, and it was because, in the html file's script tag, I had changed and not updated the src="path" to a valid path. I had a wrong directory listed in the path. For me, it's correct now with:
<script type="text/javascript" src="clienttest/clienttest.nocache.js"></script>
I rebuilt, and the image appeared on the page. This problem was keeping the entry point module from loading.