HBCMS更多的中文手册参考:

SECURITY Attribute

DHTML文档教程

Sets the value indicating whether the source file of a frame or iframe has specific security restrictions applied.

dhtml语法

HTML <ELEMENT SECURITY=sSecure ... >
ScriptingN/A

DHTML可能的值

sSecureString that specifies one of the following values.
restrictedApplies security settings to frame or iframe source files.

Remarks

Note  sSecure must specify the value restricted.

The SECURITY attribute applies the user's security settings of Restricted Sites to the source file of a frame or iframe. These security setting are found on the Security tab of the Internet Options dialog box found on the Tools menu. Changing these setting could have various results including scripting to be allowed.

Independent of user security settings, the SECURITY attribute effects hyperlink behaviors inside a restricted frame or iframe in the following two ways.

  • Hyperlinks render in a new browser window. This happens even when the TARGET attribute specifies hyperlinks to render within a restricted frame or a frame nested within the restricted frame. For example, clicking on a hyperlink within the iframe below causes a new browser window to open with the requested document.
    <IFRAME SECURITY="restricted" src="/hbcms/php/r.php?url=http%3A%2F%2Fwww.microsoft.com"></IFRAME>
  • The SECURITY attribute restricts use of the javascript, vbscript, and about protocols in URLs. For example, in a restricted frame or iframe, the source file would not be able to execute the following code.
    <A href="javascript:alert('will not work in restricted frame or iframe!');">
    JavaScript Link</A>
    

As usual, you can access the properties and contents of a restricted frame or iframe through the Document Object Model (DOM) of the container document.

If a frame is restricted by the SECURITY attribute, all nested frames share the same restrictions.

Because SECURITY is an attribute only, it must be defined in the frame element declaration.

DHTML代码范例

The following example shows how to give the user the choice of loading a document into a restricted or unrestricted iframe. Note that the createelement method is used to create the two iframes. the createelement method must use an html string for the parameter to specify the security attribute dynamically. this is because once the iframe is parsed into the document, it cannot be altered.

<HTML>
<HEAD>
<SCRIPT>
var bRestShown = false;
var bUnRestShown = false;
function createIframe(){
var sContents;
if (event.srcElement.id=="restricted" && bRestShown!=true){
sContents = "<IFRAME SECURITY='restricted' SRC='frameSource.htm'>"
var newIframe = document.createElement(sContents);
restIframe.appendChild(newIframe);}
else if (event.srcElement.id=="unrestricted" && bUnRestShown!=true){
sContents = "<IFRAME SRC='frameSource.htm'>"
var newIframe = document.createElement(sContents);
unRestIframe.appendChild(newIframe);}
}
</SCRIPT>
</HEAD>
<BODY>
<table>
<TR>
<TD><INPUT ID="restricted" TYPE="BUTTON" ONCLICK="createIframe();bRestShown=true;"
VALUE="Create Restricted IFRAME"></TD>
<TD><INPUT ID="unrestricted" TYPE="BUTTON" ONCLICK="createIframe();bUnRestShown=true;" VALUE="Create Unrestricted IFRAME"></TD>
</TR>
<tr>
<td>
<b>IFRAME with SECURITY="restricted"</b>
</td>
<td>
<b>IFRAME without SECURITY attribute</b>
</td>
</tr>
<TR>
<td>
<SPAN id="restIframe"></SPAN>
</td>
<td>
<SPAN id="unRestIframe"></SPAN>
</td>
</tr>
</table>
<BODY>
</HTML>
This feature requires Microsoft® Internet Explorer 6 or later. Click the following icon to install the latest version. Then reload this page to view the sample.

applies to

FRAME, IFRAME