Différences entre les versions de « Les scripts de Maxthon v2.0 »

De Wiki Francophone de Maxthon
Aller à la navigation Aller à la recherche
Ligne 68 : Ligne 68 :


====Example:====
====Example:====
[javascript:v() [Demo 1]]
<div style="margin: 5px;padding: 10px;background: #F3F3F3;border: 1px dashed #CCCCCC;"><span style="color: #000066;font-weight: bold;">alert</span>(<span style="color: #0000FF;">'Maxthon Version: '</span>+<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">max_version</span>);</div></div>
<div style="margin: 5px;padding: 10px;background: #F3F3F3;border: 1px dashed #CCCCCC;"><span style="color: #000066;font-weight: bold;">alert</span>(<span style="color: #0000FF;">'Maxthon Version: '</span>+<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">max_version</span>);</div></div>


Ligne 85 : Ligne 83 :


====Example:====
====Example:====
[javascript:v() [Demo 1]]
<span style="color: #000066;font-weight: bold;">alert</span>(<span style="color: #0000FF;">'Language ID='</span>+<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">max_language_id</span>);
<span style="color: #000066;font-weight: bold;">alert</span>(<span style="color: #0000FF;">'Language ID='</span>+<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">max_language_id</span>);
</div>
</div>




====current_tab '''(formerly''' cur_sel ''')''' <span style="color: #FFFFFF;background-color: #CC0000;">Not Implemented</span>====
====current_tab==== '''(formerly''' cur_sel ''')''' <span style="color: #FFFFFF;background-color: #CC0000;">Not Implemented</span>
 
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Remarks:=====
=====Remarks:=====
  This property will return an integer number as the index of the tab which is activated.<br /><span style="color: #990000;">null</span> will be returned if there is no tab opened.<br /><span style="color: #000066;font-weight: bold;">current_tab</span><span style="color: #CC0000;font-weight: bold;"> is introduced in Maxthon 2.0 as a replacement of </span><span style="color: #000066;font-weight: bold;">cur_sel</span><span style="color: #CC0000;font-weight: bold;"> because the old property name is too obscure to understand.</span><br /><br />
  This property will return an integer number as the index of the tab which is activated.<br /><span style="color: #990000;">null</span> will be returned if there is no tab opened.<br /><span style="color: #000066;font-weight: bold;">current_tab</span><span style="color: #CC0000;font-weight: bold;"> is introduced in Maxthon 2.0 as a replacement of </span><span style="color: #000066;font-weight: bold;">cur_sel</span><span style="color: #CC0000;font-weight: bold;"> because the old property name is too obscure to understand.</span><br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 2.0+ (use <span style="color: #000066;font-weight: bold;">cur_sel</span> for 1.x versions)<br /><br />
  Maxthon Version 2.0+ (use <span style="color: #000066;font-weight: bold;">cur_sel</span> for 1.x versions)<br /><br />


=====Example:=====
=====Example:=====
[javascript:v() [Demo 1]]
<div style="margin: 5px;padding: 10px;background: #F3F3F3;border: 1px dashed #CCCCCC;"><span style="color: #000066;font-weight: bold;">alert</span>(<span style="color: #0000FF;">'Current Tab Index: '</span>+<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">current_tab</span>);</div></div>
<div style="margin: 5px;padding: 10px;background: #F3F3F3;border: 1px dashed #CCCCCC;"><span style="color: #000066;font-weight: bold;">alert</span>(<span style="color: #0000FF;">'Current Tab Index: '</span>+<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">current_tab</span>);</div></div>




====tab_count====
====tab_count====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Remarks:=====
=====Remarks:=====
  This property will return current tab count as an integer.<br /><br />
  This property will return current tab count as an integer.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.0+<br /><br />
  Maxthon Version 1.0+<br /><br />


=====Example:=====
=====Example:=====
[javascript:v() [Demo 1]]
<span style="color: #000066;font-weight: bold;">alert</span>(<span style="color: #0000FF;">'Tabs Count: '</span>+<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">tab_count</span>);
<span style="color: #000066;font-weight: bold;">alert</span>(<span style="color: #0000FF;">'Tabs Count: '</span>+<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">tab_count</span>);
</div>
</div>


Ligne 135 : Ligne 117 :


====addFavorite(''url'' '''[''', ''title''''']''')====
====addFavorite(''url'' '''[''', ''title''''']''')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''url'' : string<br /> The url to add.<br /><br />''title'' : string<br /> Optional. The title of the url.<br /><br />
''url'' : string<br /> The url to add.<br /><br />''title'' : string<br /> Optional. The title of the url.<br /><br />


=====Remarks:=====
=====Remarks:=====
  Show the Add Favorite dialog to ask user to add a new Favorites Item.<br /> This function will return <span style="color: #CC0000;font-weight: bold;">false</span> if user cancelled this operation.<br /><br />
  Show the Add Favorite dialog to ask user to add a new Favorites Item.<br /> This function will return <span style="color: #CC0000;font-weight: bold;">false</span> if user cancelled this operation.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.0+<br /><br />
  Maxthon Version 1.0+<br /><br />


=====Example:=====
=====Example:=====
[javascript:v() [Demo 1]]
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">addFavorite</span>(<span style="color: #0000FF;">"http://www.maxthon.com"</span>);
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">addFavorite</span>(<span style="color: #0000FF;">"http://www.maxthon.com"</span>);
[javascript:v() [Demo 2]]


<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">addFavorite</span>(<span style="color: #0000FF;">"http://www.maxthon.com"</span>, <span style="color: #0000FF;">"Maxthon Official Site"</span>);
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">addFavorite</span>(<span style="color: #0000FF;">"http://www.maxthon.com"</span>, <span style="color: #0000FF;">"Maxthon Official Site"</span>);
</div>
</div>




====addProxy(''name'', ''address'', ''type'')====
====addProxy(''name'', ''address'', ''type'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''name'' : string<br /> The display name of proxy.<br /><br />''address'' : string<br /> The IP address or Domain name of proxy.<br /><br />''type'' : integer<br /> A number indicates the speed rating of proxy.<br /> = HTTP Proxy, <span style="color: #FF6600;">1</span> = SOCKS4A Proxy, <span style="color: #FF6600;">2</span> = SOCKS5 Proxy<br /><br />
''name'' : string<br /> The display name of proxy.<br /><br />''address'' : string<br /> The IP address or Domain name of proxy.<br /><br />''type'' : integer<br /> A number indicates the speed rating of proxy.<br /> = HTTP Proxy, <span style="color: #FF6600;">1</span> = SOCKS4A Proxy, <span style="color: #FF6600;">2</span> = SOCKS5 Proxy<br /><br />


=====Remarks:=====
=====Remarks:=====
  Add a new proxy into Maxthon's proxy list. A dialog will be shown to the user.<br /> This function will return <span style="color: #CC0000;font-weight: bold;">false</span> if user cancelled this operation.<br /><br />
  Add a new proxy into Maxthon's proxy list. A dialog will be shown to the user.<br /> This function will return <span style="color: #CC0000;font-weight: bold;">false</span> if user cancelled this operation.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 2.0+<br /><br />
  Maxthon Version 2.0+<br /><br />


=====Example:=====
=====Example:=====
[javascript:v() [Demo 1]]
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">addProxy</span>(<span style="color: #0000FF;">"My proxy"</span>,<span style="color: #0000FF;">"192.168.1.0:8080"</span>, <span style="color: #FF6600;">1</span>);
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">addProxy</span>(<span style="color: #0000FF;">"My proxy"</span>,<span style="color: #0000FF;">"192.168.1.0:8080"</span>, <span style="color: #FF6600;">1</span>);
</div>
</div>




====addFilter(''url_mask'', ''type'')====
====addFilter(''url_mask'', ''type'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''url_mask'' : string<br /> Address mask to match blocked addresses. Supports Regular Expression.<br /><br />''type'' : integer<br /> A number indicates which Filter list to add.<br /> = Popup Filter, <span style="color: #FF6600;">1</span> = Content Filter<br /><br />
''url_mask'' : string<br /> Address mask to match blocked addresses. Supports Regular Expression.<br /><br />''type'' : integer<br /> A number indicates which Filter list to add.<br /> = Popup Filter, <span style="color: #FF6600;">1</span> = Content Filter<br /><br />


=====Remarks:=====
=====Remarks:=====
  Add a new filter policy into Maxthon. A dialog will be shown to the user.<br /> This function will return '''false''' if user cancelled this operation.<br /><br />
  Add a new filter policy into Maxthon. A dialog will be shown to the user.<br /> This function will return '''false''' if user cancelled this operation.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 2.0+<br /><br />
  Maxthon Version 2.0+<br /><br />


=====Example:=====
=====Example:=====
[javascript:v() [Demo 1]]
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">addFilter</span>(<span style="color: #0000FF;">"http://www.advertisement.com/img/*"</span>, );
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">addFilter</span>(<span style="color: #0000FF;">"http://www.advertisement.com/img/*"</span>, );
</div>
</div>




====max_addProxyProvider(''URL'')====
====max_addProxyProvider(''URL'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''URL'' : string<br /> The URL of proxy list file. File format please refer to [proxyprovider.htm this document].<br /><br />
''URL'' : string<br /> The URL of proxy list file. File format please refer to [proxyprovider.htm this document].<br /><br />


=====Remarks:=====
=====Remarks:=====
  Add a new Proxy Provider into Maxthon Broser. A dialog will be shown to the user.<br /> This function will return <span style="color: #CC0000;font-weight: bold;">false</span> if user cancelled this operation.<br /><br />
  Add a new Proxy Provider into Maxthon Broser. A dialog will be shown to the user.<br /> This function will return <span style="color: #CC0000;font-weight: bold;">false</span> if user cancelled this operation.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 2.0+<br /><br />
  Maxthon Version 2.0+<br /><br />


=====Example:=====
=====Example:=====
[javascript:v() [Demo 1]]
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">max_addProxyProvider</span>(<span style="color: #0000FF;">"http://www.freeproxy.cn/m2proxy/proxylist.xml"</span>);
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">max_addProxyProvider</span>(<span style="color: #0000FF;">"http://www.freeproxy.cn/m2proxy/proxylist.xml"</span>);
</div>
</div>




====m2_run_cmd(''security_id'', ''command_id'')====
====m2_run_cmd(''security_id'', ''command_id'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''command_id'' : integer<br /> The internal command ID of Maxthon.<br /><br />
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''command_id'' : integer<br /> The internal command ID of Maxthon.<br /><br />


=====Remarks:=====
=====Remarks:=====
  This function will call a Maxthon's command with specified ''command_id''.<br /> Most usable Command IDs can be found in the language file inside Maxthon's language folder.<br /><span style="color: #CC0000;font-weight: bold;">Command ID might be different between versions. Please do not use this function if not required.</span><br /><br />
  This function will call a Maxthon's command with specified ''command_id''.<br /> Most usable Command IDs can be found in the language file inside Maxthon's language folder.<br /><span style="color: #CC0000;font-weight: bold;">Command ID might be different between versions. Please do not use this function if not required.</span><br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.0+<br /><br />
  Maxthon Version 1.0+<br /><br />


=====Example:=====
=====Example:=====
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">m2_run_cmd</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #FF6600;">32772</span>); // Open a Blank Page
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">m2_run_cmd</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #FF6600;">32772</span>); // Open a Blank Page
</div>
</div>




====m2_search_text(''security_id'')====
====m2_search_text(''security_id'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />


=====Remarks:=====
=====Remarks:=====
  This function will return the text in Maxthon's Search Box as a string.<br /><br />
  This function will return the text in Maxthon's Search Box as a string.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.2+<br /><br />
  Maxthon Version 1.2+<br /><br />


=====Example:=====
=====Example:=====
<span style="color: #000066;font-weight: bold;">var</span> searchText=<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">m2_search_text</span>(<span style="color: #0000FF;">security_id</span>);
<span style="color: #000066;font-weight: bold;">var</span> searchText=<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">m2_search_text</span>(<span style="color: #0000FF;">security_id</span>);
</div>
</div>




====m2_plugin_folder(''security_id'', ''plugin_name'')====
====m2_plugin_folder(''security_id'', ''plugin_name'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''plugin_name'' : string<br /> The name of the plugin as defined in plugin.ini.<br /><br />
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''plugin_name'' : string<br /> The name of the plugin as defined in plugin.ini.<br /><br />


=====Remarks:=====
=====Remarks:=====
  This function will return the local folder path of specified plugin as a string.<br /><br />
  This function will return the local folder path of specified plugin as a string.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.2+<br /><br />
  Maxthon Version 1.2+<br /><br />


=====Example:=====
=====Example:=====
<span style="color: #000066;font-weight: bold;">var</span> pluginPath=<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">m2_plugin_folder</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"ViewSource!"</span>);
<span style="color: #000066;font-weight: bold;">var</span> pluginPath=<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">m2_plugin_folder</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"ViewSource!"</span>);
</div>
</div>




====m2_callerName(''security_id'', ''plugin_name'')====
====m2_callerName(''security_id'', ''plugin_name'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''plugin_name'' : string<br /> The name of the plugin as defined in plugin.ini.<br /><br />
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''plugin_name'' : string<br /> The name of the plugin as defined in plugin.ini.<br /><br />


=====Remarks:=====
=====Remarks:=====
  This function will tell Maxthon the next function call is from a plugin.<br /> This function is usually used before the <span style="color: #000066;font-weight: bold;">window</span>.<span style="color: #000066;font-weight: bold;">open</span>() method to bypass the Popup Blocker of Maxthon for the plugin.<br /><br />
  This function will tell Maxthon the next function call is from a plugin.<br /> This function is usually used before the <span style="color: #000066;font-weight: bold;">window</span>.<span style="color: #000066;font-weight: bold;">open</span>() method to bypass the Popup Blocker of Maxthon for the plugin.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.2+<br /><br />
  Maxthon Version 1.2+<br /><br />


=====Example:=====
=====Example:=====
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">m2_callerName</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"ViewSource!"</span>);<br /><span style="color: #000066;font-weight: bold;">window</span>.<span style="color: #000066;font-weight: bold;">open</span>(<span style="color: #0000FF;">"about:blank"</span>);
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">m2_callerName</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"ViewSource!"</span>);<br /><span style="color: #000066;font-weight: bold;">window</span>.<span style="color: #000066;font-weight: bold;">open</span>(<span style="color: #0000FF;">"about:blank"</span>);
</div>
</div>




====max_actSideBarItem(''plugin_name'')====
====max_actSideBarItem(''plugin_name'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''plugin_name'' : string<br /> The name of the plugin as defined in plugin.ini.
''plugin_name'' : string<br /> The name of the plugin as defined in plugin.ini.


=====Remarks:=====
=====Remarks:=====
  This function will activate the sidebar plugins with the given name. <br /><br />
  This function will activate the sidebar plugins with the given name. <br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.2+<br /><br />
  Maxthon Version 1.2+<br /><br />


=====Example:=====
=====Example:=====
[javascript:v() [Demo 1]]
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">max_actSideBarItem</span>(<span style="color: #0000FF;">"Calculator++"</span>);
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">max_actSideBarItem</span>(<span style="color: #0000FF;">"Calculator++"</span>);
</div>
</div>




====max_modelessDialog(''security_id'', ''url'', ''arguments'', ''features'', ''parent_window'')====
====max_modelessDialog(''security_id'', ''url'', ''arguments'', ''features'', ''parent_window'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''url'' : string<br /> The url of modeless dialog content.<br /><br />''arguments'' : variant<br /> The arguments pass to the modeless dialog's '''window.dialogArguments''' object.<br /><br />''features'' : string<br /> A String that specifies the window ornaments for the dialog box.<br /><br />''parent_window'' : object<br /> The parent '''window''' object of the dialog.
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''url'' : string<br /> The url of modeless dialog content.<br /><br />''arguments'' : variant<br /> The arguments pass to the modeless dialog's '''window.dialogArguments''' object.<br /><br />''features'' : string<br /> A String that specifies the window ornaments for the dialog box.<br /><br />''parent_window'' : object<br /> The parent '''window''' object of the dialog.


=====Remarks:=====
=====Remarks:=====
  This function is almost the same as '''window.showModelessDialog()''' but with two more parameters.<br /> With the ''security_id'' your plugin can bypass Maxthon's Popup Blocker.<br /> With the ''parent_window'' you can make the dialog being a child of another tab's '''window'''.<br /><br />
  This function is almost the same as '''window.showModelessDialog()''' but with two more parameters.<br /> With the ''security_id'' your plugin can bypass Maxthon's Popup Blocker.<br /> With the ''parent_window'' you can make the dialog being a child of another tab's '''window'''.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.2+<br /><br />
  Maxthon Version 1.2+<br /><br />


=====Example:=====
=====Example:=====
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">max_modelessDialog</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"about:blank"</span>, {"userid": 7, "key": "d3fe3asd"}, <span style="color: #0000FF;">"status:no; help:no; resizable:yes; scroll:yes;"</span>, window);
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">max_modelessDialog</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"about:blank"</span>, {"userid": 7, "key": "d3fe3asd"}, <span style="color: #0000FF;">"status:no; help:no; resizable:yes; scroll:yes;"</span>, window);
</div>
</div>




====get_tab(''security_id'', ''index'')====
====get_tab(''security_id'', ''index'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''index'' : integer<br /> The index of the tab to get.<br /><br />
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''index'' : integer<br /> The index of the tab to get.<br /><br />


=====Remarks:=====
=====Remarks:=====
  This function will get the '''window''' object of specified tab in Maxthon.<br /><span style="color: #990000;">null</span> will be returned if the tab does not exist.<br /><br />
  This function will get the '''window''' object of specified tab in Maxthon.<br /><span style="color: #990000;">null</span> will be returned if the tab does not exist.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.0+<br /><br />
  Maxthon Version 1.0+<br /><br />


=====Example:=====
=====Example:=====
<span style="color: #000066;font-weight: bold;">var</span> objTab=<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">get_tab</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #FF6600;">5</span>);
<span style="color: #000066;font-weight: bold;">var</span> objTab=<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">get_tab</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #FF6600;">5</span>);
</div>
</div>




====activate_tab(''security_id'', ''index'')====
====activate_tab(''security_id'', ''index'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''index'' : integer<br /> The index of the tab to be activated.<br /><br />
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''index'' : integer<br /> The index of the tab to be activated.<br /><br />


=====Remarks:=====
=====Remarks:=====
  This function will activate the specified tab in Maxthon.<br /> Nothing will happen if the tab does not exist.<br /><br />
  This function will activate the specified tab in Maxthon.<br /> Nothing will happen if the tab does not exist.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.0+<br /><br />
  Maxthon Version 1.0+<br /><br />


=====Example:=====
=====Example:=====
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">activate_tab</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #FF6600;">1</span>);
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">activate_tab</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #FF6600;">1</span>);
</div>
</div>




====close_tab(''security_id'', ''index'')====
====close_tab(''security_id'', ''index'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''index'' : integer<br /> Integer. The index of the tab to close.<br /><br />
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''index'' : integer<br /> Integer. The index of the tab to close.<br /><br />


=====Remarks:=====
=====Remarks:=====
  This function will close the tab which ''index'' represents.<br /> Nothing will happen if the tab does not exist.<br /><br />
  This function will close the tab which ''index'' represents.<br /> Nothing will happen if the tab does not exist.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.0+<br /><br />
  Maxthon Version 1.0+<br /><br />


=====Example:=====
=====Example:=====
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">close_tab</span>(<span style="color: #0000FF;">security_id</span>, );
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">close_tab</span>(<span style="color: #0000FF;">security_id</span>, );
</div>
</div>




====readFile(''security_id'', ''plugin_name'', ''file_name'')====
====readFile(''security_id'', ''plugin_name'', ''file_name'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''plugin_name'' : string<br /> The name of calling plugin as defined in plugin.ini<br /><br />''file_name'' : string<br /> The file to read.<br /><br />
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''plugin_name'' : string<br /> The name of calling plugin as defined in plugin.ini<br /><br />''file_name'' : string<br /> The file to read.<br /><br />


=====Remarks:=====
=====Remarks:=====
  This function can only be used in a plugin.<br /> The function will return the file content in string when success.<br /> If the plugin is not enabled or the ''plugin_name'' is not found, the function will fail and return '''null'''.<br /><br />
  This function can only be used in a plugin.<br /> The function will return the file content in string when success.<br /> If the plugin is not enabled or the ''plugin_name'' is not found, the function will fail and return '''null'''.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.0+<br /><br />
  Maxthon Version 1.0+<br /><br />


=====Example:=====
=====Example:=====
<span style="color: #000066;font-weight: bold;">var</span> strFile=<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">readFile</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"Test plugin"</span>, <span style="color: #0000FF;">"plugin.ini"</span>);<br />
<span style="color: #000066;font-weight: bold;">var</span> strFile=<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">readFile</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"Test plugin"</span>, <span style="color: #0000FF;">"plugin.ini"</span>);<br />
</div>
</div>




====writeFile(''security_id'', ''plugin_name'', ''file_name'', ''content'')====
====writeFile(''security_id'', ''plugin_name'', ''file_name'', ''content'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''plugin_name'' : string<br /> The name of calling plugin as defined in plugin.ini<br /><br />''file_name'' : string<br /> The file to write.<br /><br />''content'' : string<br /> File content string to write.<br /><br />
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''plugin_name'' : string<br /> The name of calling plugin as defined in plugin.ini<br /><br />''file_name'' : string<br /> The file to write.<br /><br />''content'' : string<br /> File content string to write.<br /><br />


=====Remarks:=====
=====Remarks:=====
  This function can only be used in a plugin.<br /> This function will return <span style="color: #CC0000;font-weight: bold;">true</span> when success.<br /> If the file is not found, the plugin is not enabled or the ''plugin_name'' is not found, the function will fail and return <span style="color: #CC0000;font-weight: bold;">false</span>.<br /><span style="color: #CC0000;font-weight: bold;">If a file with the same name exists, it will be overwritten.</span><br /><br />
  This function can only be used in a plugin.<br /> This function will return <span style="color: #CC0000;font-weight: bold;">true</span> when success.<br /> If the file is not found, the plugin is not enabled or the ''plugin_name'' is not found, the function will fail and return <span style="color: #CC0000;font-weight: bold;">false</span>.<br /><span style="color: #CC0000;font-weight: bold;">If a file with the same name exists, it will be overwritten.</span><br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.0+<br /><br />
  Maxthon Version 1.0+<br /><br />


=====Example:=====
=====Example:=====
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">writeFile</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"Test plugin"</span>, <span style="color: #0000FF;">"setting.ini"</span>, <span style="color: #0000FF;">"username=abc\npass=qwrxcv"</span>);
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">writeFile</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"Test plugin"</span>, <span style="color: #0000FF;">"setting.ini"</span>, <span style="color: #0000FF;">"username=abc\npass=qwrxcv"</span>);
</div>
</div>




====m2_readIni(''security_id'', ''plugin_name'', ''file_name'', ''section_name'', ''key'', ''default_value'')====
====m2_readIni(''security_id'', ''plugin_name'', ''file_name'', ''section_name'', ''key'', ''default_value'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''plugin_name'' : string<br /> The name of calling plugin as defined in plugin.ini.<br /><br />''file_name'' : string<br /> The name of the INI file to read.<br /><br />''section_name'' : string<br /> The INI section to read, without brackets [ ].<br /><br />''key'' : string<br /> The key of the entry to read.<br /><br />''default_value'' : string<br /> The default value to return if the key does not exist.<br /><br />
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''plugin_name'' : string<br /> The name of calling plugin as defined in plugin.ini.<br /><br />''file_name'' : string<br /> The name of the INI file to read.<br /><br />''section_name'' : string<br /> The INI section to read, without brackets [ ].<br /><br />''key'' : string<br /> The key of the entry to read.<br /><br />''default_value'' : string<br /> The default value to return if the key does not exist.<br /><br />


=====Remarks:=====
=====Remarks:=====
  This function will read the value of ''key'' under section ''section_name'' in INI file ''file_name''.<br /> The INI file must be placed inside the folder of plugin ''plugin_name''.<br /> The value will be returned as a '''string''' if success.<br /> If the file does not exist, the section does not exist or the key does not exist, the ''default_value'' will be returned.<br /><br />
  This function will read the value of ''key'' under section ''section_name'' in INI file ''file_name''.<br /> The INI file must be placed inside the folder of plugin ''plugin_name''.<br /> The value will be returned as a '''string''' if success.<br /> If the file does not exist, the section does not exist or the key does not exist, the ''default_value'' will be returned.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.0+<br /><br />
  Maxthon Version 1.0+<br /><br />


=====Example:=====
=====Example:=====
<span style="color: #000066;font-weight: bold;">var</span> saveCount = <span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">m2_readIni</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"TestPlugin"</span>, <span style="color: #0000FF;">"settings.ini"</span>, <span style="color: #0000FF;">"general"</span>, <span style="color: #0000FF;">"saveCount"</span>, <span style="color: #0000FF;">"0"</span>);
<span style="color: #000066;font-weight: bold;">var</span> saveCount = <span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">m2_readIni</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"TestPlugin"</span>, <span style="color: #0000FF;">"settings.ini"</span>, <span style="color: #0000FF;">"general"</span>, <span style="color: #0000FF;">"saveCount"</span>, <span style="color: #0000FF;">"0"</span>);
</div>
</div>




====m2_writeIni(''security_id'', ''plugin_name'', ''file_name'', ''section_name'', ''key'', ''value'')====
====m2_writeIni(''security_id'', ''plugin_name'', ''file_name'', ''section_name'', ''key'', ''value'')====
<div style="margin-left: 10px;">
<div style="margin-left: 10px;">


=====Parameters:=====
=====Parameters:=====
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''plugin_name'' : string<br /> The name of calling plugin as defined in plugin.ini.<br /><br />''file_name'' : string<br /> The name of the INI file to write.<br /><br />''section_name'' : string<br /> The INI section to write, without brackets [ ].<br /><br />''key'' : string<br /> The key of the entry to write.<br /><br />''value'' : string/integer<br /> The value to write.<br /><br />
''security_id'' : string<br /> Maxthon's Security ID.<br /><br />''plugin_name'' : string<br /> The name of calling plugin as defined in plugin.ini.<br /><br />''file_name'' : string<br /> The name of the INI file to write.<br /><br />''section_name'' : string<br /> The INI section to write, without brackets [ ].<br /><br />''key'' : string<br /> The key of the entry to write.<br /><br />''value'' : string/integer<br /> The value to write.<br /><br />


=====Remarks:=====
=====Remarks:=====
  This function will write a ''key'' and ''value'' pair entry under section ''section_name'' in INI file ''file_name''.<br /> The INI file can only be writen inside the folder of plugin ''plugin_name''.<br /> If the file does not exist, the section does not exist or the key does not exist, they will be created automatically.<br /> This function will return <span style="color: #CC0000;font-weight: bold;">true</span> when success and <span style="color: #CC0000;font-weight: bold;">false</span> when failed.<br /><br />
  This function will write a ''key'' and ''value'' pair entry under section ''section_name'' in INI file ''file_name''.<br /> The INI file can only be writen inside the folder of plugin ''plugin_name''.<br /> If the file does not exist, the section does not exist or the key does not exist, they will be created automatically.<br /> This function will return <span style="color: #CC0000;font-weight: bold;">true</span> when success and <span style="color: #CC0000;font-weight: bold;">false</span> when failed.<br /><br />


=====Requirements:=====
=====Requirements:=====
  Maxthon Version 1.0+<br /><br />
  Maxthon Version 1.0+<br /><br />


=====Example:=====
=====Example:=====
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">m2_writeIni</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"TestPlugin"</span>, <span style="color: #0000FF;">"settings.ini"</span>, <span style="color: #0000FF;">"general</span>", <span style="color: #0000FF;">"saveCount"</span>, <span style="color: #FF6600;">25</span>);
<span style="color: #000066;font-weight: bold;">external</span>.<span style="color: #000066;font-weight: bold;">m2_writeIni</span>(<span style="color: #0000FF;">security_id</span>, <span style="color: #0000FF;">"TestPlugin"</span>, <span style="color: #0000FF;">"settings.ini"</span>, <span style="color: #0000FF;">"general</span>", <span style="color: #0000FF;">"saveCount"</span>, <span style="color: #FF6600;">25</span>);
</div>
</div>

Version du 16 août 2006 à 16:13

Version: 2.0.1 Last Modified: 2006-07-17 4:24 PM


Overview

Maxthon Browser has extended the DHTML support of IE by adding several new extensions which can be called by scripting language such as Javascript and VBScript.

These APIs can be called via the window.external object in a HTML page or a script plugin made for Maxthon Browser.

Some functions will require a security_id as first parameter. These Functions can only be used by Plugins.
In order to get a security_id for your plugin, you can do the following:

Button Plugins

Put a %max_security_id in your script, such as:

var security_id=%max_security_id;

Then you can use the variable security_id in your script.

Sidebar Plugins

A file named max.src will be created in your plugin's folder, include this file in your HTML file:

<script type="text/javascript" src="max.src"></script>

Then use variable max_security_id for security id parameter in your script.


Index

Extended Properties

General Methods

Tab Related Methods

File Related Methods


Extended Properties

max_version

Remarks:

This property will return a string of Maxthon Browser Version Number.
The return string is formatted like "2.1.0.600".

It's sugguested use this property to determine whether Maxthon Browser is running.

Requirements:

Maxthon Version 2.0+

Example:

alert('Maxthon Version: '+external.max_version);


max_language_id

Remarks:

This property will return current language id of Maxthon Browser.

The Language ID has change to use Language Identifiers defined in Microsoft Windows since Maxthon Browser 2.0.
A list of Maxthon's Language IDs can be found at:
http://msdn.microsoft.com/library/?url=/library/en-us/intl/nls_238z.asp

Requirements:

Maxthon Version 1.0+

Example:

alert('Language ID='+external.max_language_id);


====current_tab==== (formerly cur_sel ) Not Implemented

Remarks:
This property will return an integer number as the index of the tab which is activated.
null will be returned if there is no tab opened.
current_tab is introduced in Maxthon 2.0 as a replacement of cur_sel because the old property name is too obscure to understand.

Requirements:
Maxthon Version 2.0+ (use cur_sel for 1.x versions)

Example:
alert('Current Tab Index: '+external.current_tab);


tab_count

Remarks:
This property will return current tab count as an integer.

Requirements:
Maxthon Version 1.0+

Example:

alert('Tabs Count: '+external.tab_count);


General Methods

addFavorite(url [, title])

Parameters:

url : string
The url to add.

title : string
Optional. The title of the url.

Remarks:
Show the Add Favorite dialog to ask user to add a new Favorites Item.
This function will return false if user cancelled this operation.

Requirements:
Maxthon Version 1.0+

Example:

external.addFavorite("http://www.maxthon.com");

external.addFavorite("http://www.maxthon.com", "Maxthon Official Site");


addProxy(name, address, type)

Parameters:

name : string
The display name of proxy.

address : string
The IP address or Domain name of proxy.

type : integer
A number indicates the speed rating of proxy.
= HTTP Proxy, 1 = SOCKS4A Proxy, 2 = SOCKS5 Proxy

Remarks:
Add a new proxy into Maxthon's proxy list. A dialog will be shown to the user.
This function will return false if user cancelled this operation.

Requirements:
Maxthon Version 2.0+

Example:

external.addProxy("My proxy","192.168.1.0:8080", 1);


addFilter(url_mask, type)

Parameters:

url_mask : string
Address mask to match blocked addresses. Supports Regular Expression.

type : integer
A number indicates which Filter list to add.
= Popup Filter, 1 = Content Filter

Remarks:
Add a new filter policy into Maxthon. A dialog will be shown to the user.
This function will return false if user cancelled this operation.

Requirements:
Maxthon Version 2.0+

Example:

external.addFilter("http://www.advertisement.com/img/*", );


max_addProxyProvider(URL)

Parameters:

URL : string
The URL of proxy list file. File format please refer to [proxyprovider.htm this document].

Remarks:
Add a new Proxy Provider into Maxthon Broser. A dialog will be shown to the user.
This function will return false if user cancelled this operation.

Requirements:
Maxthon Version 2.0+

Example:

external.max_addProxyProvider("http://www.freeproxy.cn/m2proxy/proxylist.xml");


m2_run_cmd(security_id, command_id)

Parameters:

security_id : string
Maxthon's Security ID.

command_id : integer
The internal command ID of Maxthon.

Remarks:
This function will call a Maxthon's command with specified command_id.
Most usable Command IDs can be found in the language file inside Maxthon's language folder.
Command ID might be different between versions. Please do not use this function if not required.

Requirements:
Maxthon Version 1.0+

Example:

external.m2_run_cmd(security_id, 32772); // Open a Blank Page


m2_search_text(security_id)

Parameters:

security_id : string
Maxthon's Security ID.

Remarks:
This function will return the text in Maxthon's Search Box as a string.

Requirements:
Maxthon Version 1.2+

Example:

var searchText=external.m2_search_text(security_id);


m2_plugin_folder(security_id, plugin_name)

Parameters:

security_id : string
Maxthon's Security ID.

plugin_name : string
The name of the plugin as defined in plugin.ini.

Remarks:
This function will return the local folder path of specified plugin as a string.

Requirements:
Maxthon Version 1.2+

Example:

var pluginPath=external.m2_plugin_folder(security_id, "ViewSource!");


m2_callerName(security_id, plugin_name)

Parameters:

security_id : string
Maxthon's Security ID.

plugin_name : string
The name of the plugin as defined in plugin.ini.

Remarks:
This function will tell Maxthon the next function call is from a plugin.
This function is usually used before the window.open() method to bypass the Popup Blocker of Maxthon for the plugin.

Requirements:
Maxthon Version 1.2+

Example:

external.m2_callerName(security_id, "ViewSource!");
window.open("about:blank");


max_actSideBarItem(plugin_name)

Parameters:

plugin_name : string
The name of the plugin as defined in plugin.ini.

Remarks:
This function will activate the sidebar plugins with the given name. 

Requirements:
Maxthon Version 1.2+

Example:

external.max_actSideBarItem("Calculator++");


max_modelessDialog(security_id, url, arguments, features, parent_window)

Parameters:

security_id : string
Maxthon's Security ID.

url : string
The url of modeless dialog content.

arguments : variant
The arguments pass to the modeless dialog's window.dialogArguments object.

features : string
A String that specifies the window ornaments for the dialog box.

parent_window : object
The parent window object of the dialog.

Remarks:
This function is almost the same as window.showModelessDialog() but with two more parameters.
With the security_id your plugin can bypass Maxthon's Popup Blocker.
With the parent_window you can make the dialog being a child of another tab's window.

Requirements:
Maxthon Version 1.2+

Example:

external.max_modelessDialog(security_id, "about:blank", {"userid": 7, "key": "d3fe3asd"}, "status:no; help:no; resizable:yes; scroll:yes;", window);


get_tab(security_id, index)

Parameters:

security_id : string
Maxthon's Security ID.

index : integer
The index of the tab to get.

Remarks:
This function will get the window object of specified tab in Maxthon.
null will be returned if the tab does not exist.

Requirements:
Maxthon Version 1.0+

Example:

var objTab=external.get_tab(security_id, 5);


activate_tab(security_id, index)

Parameters:

security_id : string
Maxthon's Security ID.

index : integer
The index of the tab to be activated.

Remarks:
This function will activate the specified tab in Maxthon.
Nothing will happen if the tab does not exist.

Requirements:
Maxthon Version 1.0+

Example:

external.activate_tab(security_id, 1);


close_tab(security_id, index)

Parameters:

security_id : string
Maxthon's Security ID.

index : integer
Integer. The index of the tab to close.

Remarks:
This function will close the tab which index represents.
Nothing will happen if the tab does not exist.

Requirements:
Maxthon Version 1.0+

Example:

external.close_tab(security_id, );


readFile(security_id, plugin_name, file_name)

Parameters:

security_id : string
Maxthon's Security ID.

plugin_name : string
The name of calling plugin as defined in plugin.ini

file_name : string
The file to read.

Remarks:
This function can only be used in a plugin.
The function will return the file content in string when success.
If the plugin is not enabled or the plugin_name is not found, the function will fail and return null.

Requirements:
Maxthon Version 1.0+

Example:

var strFile=external.readFile(security_id, "Test plugin", "plugin.ini");


writeFile(security_id, plugin_name, file_name, content)

Parameters:

security_id : string
Maxthon's Security ID.

plugin_name : string
The name of calling plugin as defined in plugin.ini

file_name : string
The file to write.

content : string
File content string to write.

Remarks:
This function can only be used in a plugin.
This function will return true when success.
If the file is not found, the plugin is not enabled or the plugin_name is not found, the function will fail and return false.
If a file with the same name exists, it will be overwritten.

Requirements:
Maxthon Version 1.0+

Example:

external.writeFile(security_id, "Test plugin", "setting.ini", "username=abc\npass=qwrxcv");


m2_readIni(security_id, plugin_name, file_name, section_name, key, default_value)

Parameters:

security_id : string
Maxthon's Security ID.

plugin_name : string
The name of calling plugin as defined in plugin.ini.

file_name : string
The name of the INI file to read.

section_name : string
The INI section to read, without brackets [ ].

key : string
The key of the entry to read.

default_value : string
The default value to return if the key does not exist.

Remarks:
This function will read the value of key under section section_name in INI file file_name.
The INI file must be placed inside the folder of plugin plugin_name.
The value will be returned as a string if success.
If the file does not exist, the section does not exist or the key does not exist, the default_value will be returned.

Requirements:
Maxthon Version 1.0+

Example:

var saveCount = external.m2_readIni(security_id, "TestPlugin", "settings.ini", "general", "saveCount", "0");


m2_writeIni(security_id, plugin_name, file_name, section_name, key, value)

Parameters:

security_id : string
Maxthon's Security ID.

plugin_name : string
The name of calling plugin as defined in plugin.ini.

file_name : string
The name of the INI file to write.

section_name : string
The INI section to write, without brackets [ ].

key : string
The key of the entry to write.

value : string/integer
The value to write.

Remarks:
This function will write a key and value pair entry under section section_name in INI file file_name.
The INI file can only be writen inside the folder of plugin plugin_name.
If the file does not exist, the section does not exist or the key does not exist, they will be created automatically.
This function will return true when success and false when failed.

Requirements:
Maxthon Version 1.0+

Example:

external.m2_writeIni(security_id, "TestPlugin", "settings.ini", "general", "saveCount", 25);