summaryrefslogtreecommitdiffstats
path: root/chrome_frame/host_w_controls.html
blob: 0e44fc5d6d84cdb96a6ce1f19e70350266610fae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<HTML>
<!-- TODO(slightlyoff): Move to tests directory? -->
<HEAD>
<TITLE> Chrome Frame Test </TITLE>
<SCRIPT type="text/javascript">
function msg(txt) {
  try {
    document.getElementById("my_text").innerHTML = txt;
  } catch(e) {
    alert("error");
  }
}

function GetChromeFrame() {
  var chromeFrame = window.document.ChromeFrame
  return chromeFrame;
}

function OnChromeFrameMessage(text) {
  msg("In host:  \r\nMessage from ChromeFrame: " + text);
  
  var chromeFrame = GetChromeFrame();
  chromeFrame.PostMessageToFrame("OnHostMessage", "Hello from host");
  return "OK";
}

function OnNavigate() {
  var url = document.getElementById('inputurl');
  GetChromeFrame().src = url.value;
}

function OnFocus() {
  msg("OnFocus");
}

window.onload = function() {
  var chromeFrame = GetChromeFrame();
  var url = location.href;
  url = url.substr(0, url.lastIndexOf('/') + 1) + "frame_w_controls.html";
  chromeFrame.src = url;

  try {
    var cf = document.getElementById('ChromeFrame');
    cf.addEventListener("focus", OnFocus, true);
    cf.addEventListener("blur", function() { msg('blur'); }, true);
    msg("ready");
  } catch(e) {
    alert("error");
  }
}

function setFocusToCf() {
  var cf = document.getElementById('ChromeFrame');
  cf.focus();
  // alert(cf.hasFocus());
  return true;
}

</SCRIPT>
<style>
/* CSS magic to avoid the focus rect */
object:focus {
    outline: 0;
}
</style>
<!--
object:focus { outline: none; }
:focus { outline: none }
a:focus          { outline: 1px dotted invert }
-->
</HEAD>
<BODY>
Chrome Frame Test activex
<br><br>
<input id="inputurl" type="text" name="URL">
<input type="submit" value="Navigate" onClick="OnNavigate();"> 
<center>
<OBJECT ID="ChromeFrame" tabindex="0"
        WIDTH="500"
        HEIGHT="300"
        CODEBASE="http://www.google.com"
        CLASSID="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A">
    <!-- <PARAM NAME="BackColor" VALUE="100"> -->
    <!-- <PARAM NAME="src" VALUE="file:///z:/code/debug/test.html"> -->
    <embed ID="ChromeFramePlugin" WIDTH=500 HEIGHT=300 NAME="ChromeFrame"
        SRC="http://www.google.com" TYPE="application/chromeframe">
    </embed>
</OBJECT>
<p>To test the focus: <input id="fake_edit" type="text" name="fake"></p>
<p><button onclick="return setFocusToCf();">SetFocusToCF</button></p>
<p>
Message:<br>
<pre><p id="my_text"></p></pre>
</p>
</center>
</BODY>
</HTML>