iframe event / gwt 2.5
Hi, I want to fire a popup when i click in an iFrame and get the target element in order to recover his id. Why the ONCLICK event don't work ? The ONLOAD work perfectly. Thanks Code Sample : package com.exp.client; import com.google.gwt.user.client.DOM; import com.google.gwt.user.client.Event; import com.google.gwt.user.client.ui.Frame; import com.google.gwt.user.client.Window; public class CustomFrame extends Frame { public CustomFrame(){ sinkEvents(Event.ONCLICK); sinkEvents(Event.ONLOAD); setUrl(http://examples.roughian.com/index.htm#Listeners~EventListener;); setSize(900px,900px); } public void onBrowserEvent(Event event){ super.onBrowserEvent(event); switch (DOM.eventGetType(event)) { case Event.ONCLICK: Window.alert(ONCLICK : + event.getEventTarget().toString() ); DOM.eventPreventDefault(event); break; case Event.ONLOAD: Window.alert(ONLOAD); DOM.eventPreventDefault(event); break; } } } -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/leQwWBqEOp0J. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: iframe with GWT
Yeah, I know about the Frame element but I don't know how to edit the head and body areas inside of it or pass it HTML to fill itself with. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/v3hQkcze3VwJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: iframe with GWT
So I found this link http://bealetech.com/blogs/sean/2010/01/embedding-html-document-iframe-gwt and I got it to work using these functions: final IFrameElement iframe = Document.get().createIFrameElement(); FlowPanel innerBox = new FlowPanel() { @Override protected void onLoad() { super.onLoad(); // Fill the IFrame with the content html fillIframe(iframe, contentHtml); // Add a HEAD element to the IFrame with the appropriate CSS addHeadElement(iframe, cssUrl); }}; innerBox.getElement().appendChild(iframe); *and * private final native void fillIframe(IFrameElement iframe, String content) /*-{ var doc = iframe.document; if(iframe.contentDocument) doc = iframe.contentDocument; // For NS6 else if(iframe.contentWindow) doc = iframe.contentWindow.document; // For IE5.5 and IE6 // Put the content in the iframe doc.open(); doc.writeln(content); doc.close(); }-*/; I tried to get the head function on that page to work, but wasn't sure how to pass in the HTML and write it to the head element. Right now I'm just using div style=background-color:red; font-size: 18px;Hello World/div to get the styles to work with the divs I need them to. I end up with this in the dom: diviframehtmlhead/headbodydiv style=position:fixed;top:0px;left:0px;color:red;background-color: blue; font-size:44px;Hello World/div/body/html/iframe/div It works but I would imagine there's a better way. -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/Umjuy8C7iPgJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: iframe with GWT
and the example without a line of JSNI :) but be aware of same-domain restriction when retrieving reference iframe's content. public class IframeStyleExample implements EntryPoint { public static StyleElement addStyleSheet(FrameElement frameElement, String cssText) { Document contentDocument = frameElement.getContentDocument(); Element targetElement = contentDocument.getElementsByTagName(head) .getItem(0); if(targetElement == null){ targetElement = contentDocument.getDocumentElement() .getFirstChildElement(); if(targetElement == null){ contentDocument.insertFirst(targetElement = contentDocument .createElement(head)); } } StyleElement styleElement = contentDocument.createStyleElement(); styleElement.setType(text/css); styleElement.setCssText(cssText); targetElement.insertFirst(styleElement); return styleElement; } @Override public void onModuleLoad() { final Frame frame = new Frame(); frame.addLoadHandler(new LoadHandler() { @Override public void onLoad(LoadEvent event) { FrameElement frameElement = frame.getElement().cast(); addStyleSheet(frameElement, div {background: #ff;}); } }); } } -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Re: iframe with GWT
Thanks! This looks awesome! I'll give it a try. I never would've understood enough on how GWT interacts with the DOM to do this myself, but this'll be a very educational exercise for me. Thanks again! -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/TRmeYwcG8acJ. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
iframe with GWT
I'm wondering how I can create and iframe with GWT and inject some style type=text/css body{background-color: red;} /style type of stuff into the head and then inject a bunch of divs into the body. I don't need to be able to link to them at all or apply any handlers, so I would think this would be pretty easy, but I haven't found any good ways to do this yet. I tried using an HTML object and injecting iframe code into but it wasn't taking it for some reason. Any advice is appreciated. Thanks! Cory -- You received this message because you are subscribed to the Google Groups Google Web Toolkit group. To post to this group, send email to google-web-toolkit@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.