[android-developers] Re: WebView - Unable to call a dynamically added Javascript (part of a HTML) inside a DIV using innerHTML
@Kypriakos - I am not sure that we're discussing the same thing here. I am talking about DOM manipulation for setting the HTML and you seem to be talking about HTML headers written by an AJAX call. On Oct 5, 11:08 pm, kypriakos demet...@ece.neu.edu wrote: Hi Swaroop - I posted something similar in this post. I am a bit skeptic about how the default browser deals with js/ajax in Android vs how FF works: http://groups.google.com/group/android-developers/msg/9ea3fe940a397b88 I don't seem to have an issue with the innerHTML in the script i am using as much as I do with the output HTTP headers of the request. Anything here that we can help each other with let me know. On Oct 2, 11:11 pm, Swaroop gnanaswar...@gmail.com wrote: I agree that this is more of a HTML/JS question, but I've posted it here because the Browser implementation behind WebView is Android Specific and wish to understand a generic way to put innerHTML if any one has done the same in Android Development. Android's WebView and browser implement the innerHTML in the same way that HTML spec wants, but its just different when talking about Javascript availability (in question here) Swaroop On Oct 2, 4:15 am, Doug beafd...@gmail.com wrote: This is an HTML/DOM/JavaScript question, not an Android question. The fact that what you're doing doesn't work in FF should be a clue that you're probably depending on IE-specific behavior. Consider learning to use jQuery or some other JavaScript framework to do what you need to do to manipulate the DOM and that should work OK on mobile phones. Doug -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: WebView - Unable to call a dynamically added Javascript (part of a HTML) inside a DIV using innerHTML
Hi Swaroop - I posted something similar in this post. I am a bit skeptic about how the default browser deals with js/ajax in Android vs how FF works: http://groups.google.com/group/android-developers/msg/9ea3fe940a397b88 I don't seem to have an issue with the innerHTML in the script i am using as much as I do with the output HTTP headers of the request. Anything here that we can help each other with let me know. On Oct 2, 11:11 pm, Swaroop gnanaswar...@gmail.com wrote: I agree that this is more of a HTML/JS question, but I've posted it here because the Browser implementation behind WebView is Android Specific and wish to understand a generic way to put innerHTML if any one has done the same in Android Development. Android's WebView and browser implement the innerHTML in the same way that HTML spec wants, but its just different when talking about Javascript availability (in question here) Swaroop On Oct 2, 4:15 am, Doug beafd...@gmail.com wrote: This is an HTML/DOM/JavaScript question, not an Android question. The fact that what you're doing doesn't work in FF should be a clue that you're probably depending on IE-specific behavior. Consider learning to use jQuery or some other JavaScript framework to do what you need to do to manipulate the DOM and that should work OK on mobile phones. Doug -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: WebView - Unable to call a dynamically added Javascript (part of a HTML) inside a DIV using innerHTML
Thanks Doug, I will try to implement the same in JQuery and see if the results are any different and post back here. On Oct 4, 2:35 am, Doug beafd...@gmail.com wrote: On Oct 2, 8:11 pm, Swaroop gnanaswar...@gmail.com wrote: I agree that this is more of a HTML/JS question, but I've posted it here because the Browser implementation behind WebView is Android Specific and wish to understand a generic way to putinnerHTMLif any one has done the same in Android Development. Android's WebView and browser implement theinnerHTMLin the same way that HTML spec wants, but its just different when talking about Javascript availability (in question here) Android WebView just uses WebKit, so if you can get your code to work on Safari or Chrome (which both use WebKit), then you should be OK. Again, jQuery or any modern JS framework will abstract away any implementation-specific details in dealing with the DOM. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: WebView - Unable to call a dynamically added Javascript (part of a HTML) inside a DIV using innerHTML
On Oct 2, 8:11 pm, Swaroop gnanaswar...@gmail.com wrote: I agree that this is more of a HTML/JS question, but I've posted it here because the Browser implementation behind WebView is Android Specific and wish to understand a generic way to put innerHTML if any one has done the same in Android Development. Android's WebView and browser implement the innerHTML in the same way that HTML spec wants, but its just different when talking about Javascript availability (in question here) Android WebView just uses WebKit, so if you can get your code to work on Safari or Chrome (which both use WebKit), then you should be OK. Again, jQuery or any modern JS framework will abstract away any implementation-specific details in dealing with the DOM. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: WebView - Unable to call a dynamically added Javascript (part of a HTML) inside a DIV using innerHTML
I agree that this is more of a HTML/JS question, but I've posted it here because the Browser implementation behind WebView is Android Specific and wish to understand a generic way to put innerHTML if any one has done the same in Android Development. Android's WebView and browser implement the innerHTML in the same way that HTML spec wants, but its just different when talking about Javascript availability (in question here) Swaroop On Oct 2, 4:15 am, Doug beafd...@gmail.com wrote: This is an HTML/DOM/JavaScript question, not an Android question. The fact that what you're doing doesn't work in FF should be a clue that you're probably depending on IE-specific behavior. Consider learning to use jQuery or some other JavaScript framework to do what you need to do to manipulate the DOM and that should work OK on mobile phones. Doug -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: WebView - Unable to call a dynamically added Javascript (part of a HTML) inside a DIV using innerHTML
Just wanted to add that I experimented out a little with using an iFrame (it finds the Javascript, but there's a huge problem with the scope). I want any JS functions between Outer document and inner container (dynamically added) to be flexible to call each other (like how its behaving on a DIV). I am back to square one - Need something approach like the DIV container where the JS would be accessible (like how its working on the IE). Uploaded the modified version on http://pastebin.com/MhTkdhFQ / html head script /* the input type = hidden is necessary or the JS won't be accessible */ /* script defer tag is also necessary */ function insertHTMLOnButtonPress() { try { var s = htmlinput type='hidden' id='dummyHidden'/ headscript defer='defer'function dynamicallyInsertedFunction() { alert('Successfully called - dynamicallyInsertedFunction'); } /sc + ript/headbodyinput type='text' value='Hello World'/input type='button' onClick='dynamicallyInsertedFunction();' value='Call Dynamically Inserted Method'//body/html; var x = document.getElementById('test'); var y=(x.contentWindow || x.contentDocument); if (y.document)y=y.document; y.write(s); } catch(ex) { alert(ex.name); } } /script /head body **br/ !-- Don't close the div inline, causes some problem and replaces the buttons too -- iframe id=test name=testhello world/iframe **br/ input type=button onClick=insertHTMLOnButtonPress(); value=Insert some dynamic html/ input type=button onClick=dynamicallyInsertedFunction(); value=Call Dynamically Inserted Method/ /body /html / On Oct 1, 2:14 pm, Swaroop gnanaswar...@gmail.com wrote: Hi Android experts, I have a weird code situation where I need to have a DIV to hold dynamic HTML generated. Here I am populating the DIV using its innerHTML attribute and it works fine and dynamically adds any HTML elements that are there in the dynamic HTML. The problem I am facing now is if the dynamic (generated else where) HTML contains a list of Javascript methods, these methods aren't accessible to be callable from the buttons inside the div or outside the div ( I was able to get the requirement working in Desktop Internet Explorer 7+. This however doesn't work on Firefox too . I understand this isn't the best way, but to use addChild etc is, but then I would have to manually parse my HTML myself and construct all the child elements i.e do all that the innerHTML will do eventually (logically, i mean). Code also uploaded tohttp://pastebin.com/Q6w5hRPG Code works on Internet Explorer 7+// html head script /* the input type = hidden is necessary or the JS won't be accessible */ /* script defer tag is also necessary */ function insertHTMLOnButtonPress() { var s = htmlinput type='hidden' id='dummyHidden'/headscript defer='defer'function dynamicallyInsertedFunction() { alert('Successfully called - dynamicallyInsertedFunction'); } /sc + ript/headbodyinput type='text' value='Hello World'/input type='button' onClick='dynamicallyInsertedFunction();' value='Call Dynamically Inserted Method'//body/html; /* Clearing out innerHTML is also required to flush the innerHTML so that repeated attempts - i.e new HTML/JS should work */ document.getElementById('tempBody').innerHTML = ''; document.getElementById('tempBody').innerHTML = s; } /script /head body **br/ !-- Don't close the div inline, causes some problem and replaces the buttons too -- div id=tempBody/div **br/ input type=button onClick=insertHTMLOnButtonPress(); value=Insert some dynamic html/ input type=button
[android-developers] Re: WebView - Unable to call a dynamically added Javascript (part of a HTML) inside a DIV using innerHTML
This is an HTML/DOM/JavaScript question, not an Android question. The fact that what you're doing doesn't work in FF should be a clue that you're probably depending on IE-specific behavior. Consider learning to use jQuery or some other JavaScript framework to do what you need to do to manipulate the DOM and that should work OK on mobile phones. Doug -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en