XFormsBrowser.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. XFormsBrowser.prototype = new XFormsControl;
  2. function XFormsBrowser (strParentId, strAlert, strHelp, strHint, strAccesskey, strClass, bDisabled, strId, nNavindex, strSrc, strStyle, strTag, strVisibility, strUserDefineAttrib)
  3. {
  4. XFormsControl.call(this, strParentId, strAlert, strHelp, strHint, strAccesskey, strClass, bDisabled, strId, nNavindex, strStyle, strTag, strVisibility, strUserDefineAttrib);
  5. this.attribute["src"] = strSrc;
  6. this.document;
  7. this.window;
  8. };
  9. XFormsBrowser.prototype.init = function ()
  10. {
  11. XFormsControl.prototype.init.call(this);
  12. this.document = this.m_heControl.contentWindow.document;
  13. this.window = this.m_heControl.contentWindow;
  14. this.resizeControl();
  15. var strId = this.id;
  16. if (this.m_heControl.attachEvent)
  17. {
  18. this.m_heControl.attachEvent("onload", function() {XFormsBrowser.setIviewerDoc(strId);});
  19. }
  20. else
  21. {
  22. this.m_heControl.addEventListener("load", function() {XFormsBrowser.setIviewerDoc(strId);}, false);
  23. }
  24. };
  25. XFormsBrowser.prototype.setAttribute = function (strAttribute, strValue)
  26. {
  27. switch (strAttribute)
  28. {
  29. case "src":
  30. {
  31. this.attribute["src"] = strValue;
  32. this.m_heControl.src = strValue;
  33. break;
  34. }
  35. default:
  36. {
  37. break;
  38. }
  39. }
  40. };
  41. XFormsBrowser.prototype.Stop = function ()
  42. {
  43. if (is_ie)
  44. {
  45. this.m_heControl.contentWindow.document.execCommand('Stop');
  46. }
  47. else
  48. {
  49. // TODO 동작확인 해야함.
  50. this.m_heControl.contentWindow.stop();
  51. }
  52. };
  53. XFormsBrowser.prototype.Refresh = function ()
  54. {
  55. // TODO firefox 동작확인해야함
  56. this.m_heControl.contentWindow.location.reload(false);
  57. };
  58. XFormsBrowser.prototype.Navigate = function (strNewURL)
  59. {
  60. if (is_ie)
  61. {
  62. this.m_heControl.contentWindow.navigate(strNewURL);
  63. }
  64. else
  65. {
  66. this.m_heControl.contentWindow.location.href = strNewURL;
  67. }
  68. };
  69. XFormsBrowser.prototype.GoBack = function ()
  70. {
  71. // TODO firefox 동작확인해야함
  72. if(history)
  73. {
  74. this.m_heControl.contentWindow.history.back();
  75. }
  76. else
  77. {
  78. this.m_heControl.contentWindow.back();
  79. }
  80. };
  81. XFormsBrowser.prototype.GoForward = function ()
  82. {
  83. // TODO firefox 동작확인해야함
  84. if(history)
  85. {
  86. this.m_heControl.contentWindow.history.forward();
  87. }
  88. else
  89. {
  90. this.m_heControl.contentWindow.forward();
  91. }
  92. };
  93. XFormsBrowser.create = function (strParentId, clAttribute, strStyle)
  94. {
  95. // 메인노드 생성
  96. var xnBrowser = XFormsBrowser.createMainNode(clAttribute);
  97. var xnParent = document.getElementById("HE_"+strParentId);
  98. xnParent.appendChild(xnBrowser);
  99. // 하위노드 생성
  100. xnBrowser = XFormsBrowser.createSubNodes(xnBrowser, clAttribute);
  101. // object 생성
  102. return XFormsBrowser.createObject(strParentId, xnBrowser, clAttribute, strStyle);
  103. };
  104. XFormsBrowser.createMainNode = function (clAttribute)
  105. {
  106. var xnBrowser = document.createElement("iframe");
  107. xnBrowser = XFormsBrowser.createAttribute(xnBrowser, clAttribute);
  108. xnBrowser.frameBorder = "0";
  109. return xnBrowser;
  110. };
  111. XFormsBrowser.createSubNodes = function (xnBrowser, clAttribute)
  112. {
  113. return xnBrowser;
  114. };
  115. XFormsBrowser.createObject = function (strParentId, xnBrowser, clAttribute, strStyle)
  116. {
  117. var bDisabled = false;
  118. var strId = "";
  119. var nNavindex = 9007199254740992;
  120. var strSrc = "";
  121. var strUserDefineAttrib = "";
  122. for (var i=0; i<clAttribute.count(); i++)
  123. {
  124. var strAttributeName = clAttribute.keys()[i];
  125. switch (strAttributeName)
  126. {
  127. case "disabled" :
  128. {
  129. if ("true" == clAttribute.item(strAttributeName))
  130. {
  131. bDisabled = true;
  132. }
  133. break;
  134. }
  135. case "id" :
  136. {
  137. strId = clAttribute.item(strAttributeName);
  138. break;
  139. }
  140. case "navindex" :
  141. {
  142. nNavindex = parseInt(clAttribute.item(strAttributeName));
  143. break;
  144. }
  145. case "src" :
  146. {
  147. strRef = clAttribute.item(strAttributeName);
  148. break;
  149. }
  150. default :
  151. {
  152. if (!STYLE_LIST[strAttributeName])
  153. {
  154. strUserDefineAttrib += strAttributeName + ":" + clAttribute.item(strAttributeName) + "; ";
  155. }
  156. break;
  157. }
  158. }
  159. }
  160. var objBrowser = new XFormsBrowser (strParentId, "", "", "", "", "", bDisabled, strId, nNavindex, strSrc, strStyle, "xforms:browser", "visible", strUserDefineAttrib);
  161. return objBrowser;
  162. };
  163. XFormsBrowser.createAttribute = function (xnHtmlNode, clAttribute)
  164. {
  165. xnHtmlNode = XFormsControl.createAttribute(xnHtmlNode, clAttribute);
  166. return xnHtmlNode;
  167. };
  168. XFormsBrowser.setIviewerDoc = function (strId)
  169. {
  170. try
  171. {
  172. var objBrowser = document.controls.item(strId);
  173. objBrowser.document =objBrowser.m_heControl.contentWindow.document;
  174. objBrowser.window =objBrowser.m_heControl.contentWindow;
  175. }
  176. catch(e)
  177. {
  178. if (null != window.console)
  179. {
  180. console.log(" browser error : " + e);
  181. }
  182. }
  183. };