mymps_tpl.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. var n = 0;
  2. function displayHTML(obj) {
  3. win = window.open(" ", 'popup', 'toolbar = no, status = no, scrollbars=yes');
  4. win.document.write("" + obj.value + "");
  5. }
  6. function HighlightAll(obj) {
  7. obj.focus();
  8. obj.select();
  9. if(document.all) {
  10. obj.createTextRange().execCommand("Copy");
  11. window.status = "将模板内容复制到剪贴板";
  12. setTimeout("window.status=''", 1800);
  13. }
  14. }
  15. function findInPage(obj, str, noalert) {
  16. var txt, i, found;
  17. if(str == "") {
  18. return false;
  19. }
  20. if(document.layers) {
  21. if(!obj.find(str)) {
  22. while(obj.find(str, false, true)) {
  23. n++;
  24. }
  25. } else {
  26. n++;
  27. }
  28. if(n == 0 && !noalert) {
  29. alert("未找到指定字串。");
  30. }
  31. }
  32. if(document.all) {
  33. txt = obj.createTextRange();
  34. for(i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
  35. txt.moveStart('character', 1);
  36. txt.moveEnd('textedit');
  37. }
  38. if(found) {
  39. txt.moveStart('character', -1);
  40. txt.findText(str);
  41. txt.select();
  42. txt.scrollIntoView();
  43. n++;
  44. return true;
  45. } else {
  46. if(n > 0) {
  47. n = 0;
  48. findInPage(obj, str, noalert);
  49. } else if(!noalert) {
  50. alert("未找到指定字串。");
  51. }
  52. }
  53. }
  54. return false;
  55. }// JavaScript Document