2017-04-16 1 views
0

私の目標は、私の問題は、私は/アクセスを選択しようとしている要素は次のようにロードされていることであるFirefoxでGreasemonkeyの拡張機能を使用してmenu.htmlに配列optionsdaから値を変更することですが、フレーム選択要素

私はしばらくの間この問題を解決しようとしていました。私がsomoneが私を助けてくれるなら、私はとても幸せになれます。


私が持っているその内容が二つのファイルmain.htmlmenu.html

main.htmlは(メインのページです)

<html> 

<head> 
    <meta http-equiv="Pragma" content="no-cache"> 

    <script language="javascript"> 
     document.writeln("<frameset rows='89,*,15' border='0' frameborder='0' framespacing='0'>"); 

     // here is the menu frame 
     document.writeln("<frame src='menu.html' name='menufrm' frameborder='no' border='0' scrolling='no' target='_self' marginwidth='0' marginheight='0' noresize>"); 

     document.writeln("</frameset>"); 

    </script> 

</head> 

</html> 

menu.html

(フレーム "を通じて" ロードされます)
<html> 

<head> 
    <meta http-equiv='Pragma' content='no-cache'> 

    <link rel=stylesheet href='stylemain.css' type='text/css'> 
    <script language='javascript' src='menuBcm.js'></script> 

    <base target="_self"> 
</head> 

<body class='mainMenuBody' topmargin="0" leftmargin="0" marginwidth="0" marginheight="0"> 

    <table border="0" cellpadding="0" cellspacing="0" height="1000"> 

     <tr> 
      <td class='menu' width="170" valign="top" align="left"> 

       <script language='javascript'> 
        var options = new Array('a', 
         'b', 
         'c'); 

        // ultimate goal is to change the value of a to d above before 
        // execution of the script below  

        createBcmMenu(options); // from menuBcm.js 
        initializeDocument(); 
       </script> 

      </td> 
     </tr> 

    </table> 
</body> 

</html> 

外観このような何か:

+----------------------------+ 
| main page (192.168.1.1) | 
|       | 
| +---------------------+ | 
| | frame (192.168.1.1) | | 
| +---------------------+ | 
|       | 
+----------------------------+ 

のGreasemonkeyスクリプト:呼び出すこと

var frm = window.frames.menufrm;  
frm.options = ['d','b','c']; 
frm.createBcmMenu(options); 

保証:あなたはwindow.frames.menufrm

を使用して、フレームウィンドウにアクセスすることができ

// ==UserScript== 
// @name  a-to-d 
// @namespace namespace 
// @include  http://192.168.1.1/main.html 
// @include  http://192.168.1.1/menu.html 
// @version  1 
// @grant  none 
// @run-at  document-start 
// ==/UserScript== 

var newScript = `var options = new Array('d','b','c');` ; 

// somehow select that element below 
document.(!).innerHTML = newScript; // (!): somehow select script element in menu.html 
+2

フレームは何年も使用されていません...なぜ最初にフレームが必要ですか? – charlietfl

+1

ご意見ありがとうございます。私は元のコードの作成者ではなく、フレームを削除するコードを変更する機能はありません。 – Clone

答えて

2

その後のようなものを行います関数は再びそのフレームがロードされて元の関数呼び出しが既に実行されている前に何も変更することはできません

+0

ありがとうございました!しかし、上記のコードを実行すると、 'ReferenceError:options is not defined'が得られます。 – Clone