Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. window.location.href('http://www.wordreference.com');
  2.  
  3. function loadHTML(url, timeout) {
  4. if (timeout == undefined)
  5. timeout = 10000;
  6. var req = new XMLHttpRequest();
  7. var timer = setTimeout(function() {
  8. try {
  9. req.abort();
  10. } catch(e) {}
  11. navigator.notification.loadingStop();
  12. },timeout);
  13. req.onreadystatechange = function() {
  14. if (req.readyState == 4) {
  15. if (req.status < 300) {
  16. clearTimeout(timer);
  17.  
  18. var html = req.responseText;
  19. //just a debug print
  20. alert(html);
  21. document.write(html);
  22.  
  23. }
  24. navigator.notification.loadingStop();
  25. delete req;
  26. }
  27. };
  28. req.open('GET', url, true);
  29. req.send();
  30. }
  31.  
  32. loadHTML('http://www.wordreference.com',10000);
  33.  
  34. loadHTML('http://www.mysite.com/cgi-bin/index.py',10000)
  35.  
  36. <access subdomains="true" uri="http://www.mysite.com/" />
  37.  
  38. - (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  39. {
  40. return [super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
  41. }
  42.  
  43. - (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
  44. {
  45. NSURL *url = [request URL];
  46. if ([[url scheme] isEqualToString:@"http"] || [[url scheme] isEqualToString:@"https"]) {
  47. return YES;
  48. }
  49. else {
  50. return [ super webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType ];
  51. }
  52. }
  53.  
  54. /**
  55. * Load PhoneGap configuration from res/xml/phonegap.xml.
  56. * Approved list of URLs that can be loaded into DroidGap
  57. * <access origin="http://server regexp" subdomains="true" />
  58. * Log level: ERROR, WARN, INFO, DEBUG, VERBOSE (default=ERROR)
  59. * <log level="DEBUG" />
  60. */
  61. private void loadConfiguration() {
  62. [...]
  63.  
  64. <?xml version="1.0" encoding="UTF-8"?>
  65. <phonegap>
  66. <access origin="http://stackoverflow.com" subdomains="true" />
  67. </phonegap>
  68.  
  69. public class AndroidActivity extends DroidGap {
  70. /** Called when the activity is first created. */
  71. @Override
  72. public void onCreate(Bundle savedInstanceState) {
  73. super.onCreate(savedInstanceState);
  74.  
  75. try
  76. {
  77. super.loadUrl("file:///android_asset/www/index.html");
  78. this.appView.addJavascriptInterface(new JavaScriptInterface(), "EXTERNALLINK");
  79. }
  80. catch(Exception lException)
  81. {
  82. throw new RuntimeException("hello hello", lException);
  83. }
  84. }
  85.  
  86. class JavaScriptInterface
  87. {
  88. public void loadExternalLink(String lUrl)
  89. {
  90. try
  91. {
  92. loadUrl(lUrl);
  93. }
  94. catch(Exception lEx)
  95. {
  96. int i = 0;
  97. }
  98. }
  99. }
  100. }
  101.  
  102. super.setIntegerProperty("backgroundColor", Color.WHITE);
  103. super.setStringProperty("loadingPageDialog", "Loading page...");
  104.  
  105. super.setBooleanProperty("loadInWebView", true);
  106.  
  107. addWhiteListEntry("mydomain.com", true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement