Many things are easy to forget, so I chose to record them.
Firefox does not support the obj. innertext attribute.
The value displayed by obj. innertext alert () is undefined.
Firefox supports the innerhtml attribute but does not support innertext. If you do not want to replace innerhtml, you can use the followingCode
Because Firefox does not support document. All, document. getelementbyid ('yourid') is usually used to obtain objects for compatibility purposes ').
If (document. All) {// if not IE
// You can also use if (navigator. appname. indexof ("Explorer")>-1) // obj. innertext = "mytext";} else {obj. textcontent = "yourtext"; replaced by textcontent
}
JavaScript code compatible with Firefox and IE copied to the clipboard
When using this function in Firefox, You need to modify a Configuration:
1. Open Firefox and enter: About: config in the address bar.
2. Find signed. Applets. codebase_principal_support and set the value to true.
Function copytoclipboard (txt ){
If (window. clipboardData)
{
Window. clipboardData. cleardata ();
Window. clipboardData. setdata (text, txt );
}
Else if (navigator. useragent. indexof (opera )! =-1)
{
Window. Location = txt;
}
Else if (window. Netscape)
{
Try {
Netscape. Security. privilegemanager. enableprivilege (universalxpconnect );
}
Catch (E)
{
Alert (!! Rejected by the browser! \ N enter 'about: config' in the address bar of the browser, press enter \ n, and set 'signed. Applets. codebase_principal_support 'to 'true ');
}
VaR clip = components. classes ['@ mozilla.org/widget/clipboard=1'mirror.createinstance (components. Interfaces. nsiclipboard );
If (! Clip)
Return;
VaR trans = components. classes ['@ mozilla.org/widget/transferable00001').createinstance (components. Interfaces. nsitransferable );
If (! Trans)
Return;
Trans. adddataflavor ('text/Unicode ');
VaR STR = new object ();
VaR Len = new object ();
VaR STR = components. classes [@ mozilla.org/supports-string1_12.16.createinstance (components. Interfaces. nsisupportsstring );
VaR copytext = txt;
Str. Data = copytext;
Trans. settransferdata (text/Unicode, STR, copytext. length * 2 );
VaR clipid = components. Interfaces. nsiclipboard;
If (! Clip)
Return false;
Clip. setdata (trans, null, clipid. kglobalclipboard );
}
Return true;
}
Or use the following code with the same functions.
Function copytoclipboard (meintext)
{
If (window. clipboardData)
{
// The ie-manier
Window. clipboardData. setdata ("text", meintext );
}
Else if (window. Netscape)
{
// Dit is belangrijk Maar Staat nergens duidelijk vermeld:
// You have to sign the Code to enable this, or see notes below
Netscape. Security. privilegemanager. enableprivilege ('universalxpconnect ');
// Maak een interface naar het clipboard
VaR clip = components. classes ['@ mozilla.org/widget/clipboard=1']
. Createinstance (components. Interfaces. nsiclipboard );
If (! Clip) return;
// Alert (CLIP );
// Maak een transferable
VaR trans = components. classes ['@ mozilla.org/widget/transferable1_1']
. Createinstance (components. Interfaces. nsitransferable );
If (! Trans) return;
// Specificeer wat voor soort data we Op willen Halen; text in dit geval
Trans. adddataflavor ('text/Unicode ');
// Om de data uit de transferable te Halen hebben we 2 Nieuwe objecten
// Nodig om het in OP te slaan
VaR STR = new object ();
VaR Len = new object ();
VaR STR = components. classes ["@ mozilla.org/supports-string1_1"]
. Createinstance (components. Interfaces. nsisupportsstring );
VaR copytext = meintext;
Str. Data = copytext;
Trans. settransferdata ("text/Unicode", STR, copytext. length * 2 );
VaR clipid = components. Interfaces. nsiclipboard;
If (! Clip) return false;
Clip. setdata (trans, null, clipid. kglobalclipboard );
}
Else
{
Return false;
}
Alert ("You have copied:" + meintext );
Return false;
}
Use JavaScript to obtain the client computer name
When I learned PHP a few days ago, I wanted to obtain the client computer name. There are examples of implementation in ASP and. net, but I have never found a way to implement it in PHP. Later, I found some code in a foreign forum, which is JavaScript. However, it can only run in the IE environment and must be set to a low security level.
try
{< br> var AX = new activexobject ("wscript. network ");
document. write ('user: '+ ax. username + '
');
document. write ('computer: '+ ax. computername + '
');
}< br> catch (e)
{< br> document. write ('access to the current computer name operation denied '+'
');
}