Advertisement
Guest User

Untitled

a guest
Feb 26th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. <HTML>
  2. <HEAD>
  3. <TITLE>Custom Test</TITLE>
  4. <script langauge="javascript">
  5. function fnIsOurCustomBrowser()
  6. {
  7. //Check to see if this is our custom
  8. //browser. We just see if the function
  9. //IsOurCustomBrowser is available. By leaving
  10. //the brackets off of our function it is treated
  11. //as a property and thus allows us to check if
  12. //our method exists in the external window. If it
  13. //returns null then obviously this is not our custom
  14. //browser, so we return false.
  15. if(window.external.CB_IsOurCustomBrowser!=null)
  16. return true;
  17. else
  18. return false;
  19. }
  20.  
  21. //setup a variable to let us know if this is our
  22. //custom browser.
  23. bIsCustomBrowser = fnIsOurCustomBrowser();
  24.  
  25. if(!bIsCustomBrowser)
  26. {
  27. //You can check here to see if they have our custom browser.
  28. //If they don't you can do whatever you want, redirect them
  29. //to another page or whatever. For the purposes of this example
  30. //I will just alert them
  31. alert('You must be using Custom Browser to view this page properly.');
  32. }
  33.  
  34. function fnCallFunction()
  35. {
  36. //Call c++ function that we made
  37. //in our custom browser
  38. if(bIsCustomBrowser)
  39. window.external.CB_CustomFunction();
  40. }
  41.  
  42. function fnCallFunctionWithParams(strString, nNumber)
  43. {
  44. //Call c++ function that accepts parameters
  45. //that we made in our custom browser
  46. if(bIsCustomBrowser)
  47. window.external.CB_CustomFunctionWithParams(strString, nNumber);
  48. }
  49. </script>
  50. </HEAD>
  51. <BODY style="font-family:arial;font-size:10pt;" bgcolor="#eeeeee">
  52. <h2><b><u>Custom Web Browser Test Page</u></b></h2>
  53.  
  54. <p>Call C++ Function from javascript.</p>
  55. <input type="button" value="Click To Test" onclick="fnCallFunction();"><BR><BR><BR>
  56. <p>Call C++ Function with parameters: <BR>param1: <input type="text" name="param1" value="test" style="width:60;"> <BR>param2: <input type="text" name="param2" value="193" style="width:60;"></p>
  57. <input type="button" value="Click To Test" onclick="fnCallFunctionWithParams(document.all.param1.value,parseInt(document.all.param2.value));"><BR><BR><BR>
  58. <p>Call alert to see our custom message box</p>
  59. <input type="button" value="Click To Test" onclick="alert('Custom MessageBox Test. Notice how we have the criticl symbol now. We could literally make this messagebox be whatever we want it to be.');"><BR><BR><BR>
  60. </BODY>
  61. </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement