Common HTML skills

Source: Internet
Author: User
Tags servervariables

Q: How do I remove the scroll bar of the multiline (multi-layer) textbox?
A:
Change its style:

Textbox1.style ["overflow"] = "visible ";

<Textarea style = "overflow: visible">... </textarea>
A2: textarea style = "overflow-Y: visible;
Border: 0px; font-size: 12px; font-family: fixfixedsys;
Line-Height: 150%; overflow: visible;
Border-width: 0px; width: 550px; Height: 40px "> </textarea>

///
HTML page tips
 
1. oncontextmenu = "window. event. returnvalue = false" will completely block the right mouse button
<Table border oncontextmenu = return (false)> <TD> NO </table>

2. <body onselectstart = "Return false"> cancel selection to prevent Replication

3. onpaste = "Return false" Do not paste

4. oncopy = "Return false;" oncut = "Return false;" Prevent Replication

5. <LINK rel = "shortcut icon" href = "favicon. ICO"> replace it with your own icon in front of the IE Address Bar

6. <LINK rel = "bookmark" href = "favicon. ICO"> your Icons can be displayed in favorites.

7. <input style = "ime-mode: Disabled"> disable the input method.

8. Always carry the framework
<Script language = "JavaScript"> <! --
If (window = Top) top. Location. href = "frames.htm"; // frames.htm is the frame webpage.
// --> </SCRIPT>

9. Prevent Frame
<Script language = JavaScript> <! --
If (top. location! = Self. Location) top. Location = self. location;
// --> </SCRIPT>

10. <NoScript> <IFRAME src = *. html> </iframe> </NoScript> webpages cannot be saved

11. <input type = button value = view web pageSource code
Onclick = "window. Location = ''view-Source:'' + ''http: // www.csdn.net/'' ">

12. How to use ASP to check whether the visitor has used an agent?
<% If request. servervariables ("http_x_forwarded_for") <> "then
Response. Write "<font color = # ff0000> you have passed the proxy server ,"&_
"The real IP address is" & request. servervariables ("http_x_forwarded_for ")
End if
%>

13. Obtain the absolute position of the control

// Javascript
<Script language = "JavaScript">
Function getie (e ){
VaR T = E. offsettop;
VaR L = E. offsetleft;
While (E = E. offsetparent ){
T + = E. offsettop;
L + = E. offsetleft;
}
Alert ("Top =" + T + "\ nleft =" + l );
}
</SCRIPT>

// VBScript
<Script language = "VBScript"> <! --
Function getie ()
Dim t, L, A, B
Set a = Document. All. img1
T = Document. All. img1.offsettop
L = Document. All. img1.offsetleft
While a. tagname <> "body"
Set a = A. offsetparent
T = T + A. offsettop
L = L + A. offsetleft
Wend
Msgbox "Top =" & T & CHR (13) & "Left =" & L, 64, "Get control position"
End Function
--> </SCRIPT>

14. The cursor stops at the end of the text box.
<Script language = "JavaScript">
Function CC ()
{
VaR E = event. srcelement;
VaR r = E. createTextRange ();
R. movestart (''character'', E. value. Length );
R. Collapse (true );
R. Select ();
}
</SCRIPT>
<Input type = text name = text1 value = "123" onfocus = "CC ()">

15. determine the source of the previous page
ASP:
Request. servervariables ("http_referer ")

Java Script:
Document. referrer

16. Minimize, maximize, and close the window
<Object ID = HH1 classid = "CLSID: ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<Param name = "command" value = "minimize"> </Object>
<Object ID = HH2 classid = "CLSID: ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<Param name = "command" value = "maximize"> </Object>
<Object ID = hh3 classid = "CLSID: adb880a6-d8ff-11cf-9377-00aa003b7a11">
<Param name = "command" value = "close"> </Object>

<Input type = button value = minimized onclick = hh1.click ()>
<Input type = button value = maximized onclick = hh2.click ()>
<Input type = button value = Disable onclick = hh3.click ()>
This example applies to IE

17.
<%
''Defines some constants for database connection
Const adopenforwardonly = 0'' the cursor only views records forward. pagination, recordset, and bookmark are not supported.
Const adopenkeyset = 1' indicates the keyset cursor. modifications made by other users to the record are reflected in the record set. However, adding or deleting records by other users is not reflected in the record set. Supports paging, recordset, and bookmark
Const adopendynamic = 2' the most dynamic cursor function, but the most resource consumption. The added or deleted records modified by the user on the record description will be reflected in the record set. Supports full-featured browsing (access is not supported ).
Const adopenstatic = 3' static cursor, which is only a snapshot of the data. The added or deleted records modified by the user on the record are not reflected in the record set. Supports moving forward or backward

Const adlockreadonly = 1' lock type, default, read-only, cannot be modified
Const adlockpessimistic = 2' lock the record immediately when editing, the safest way
Const adlockoptimistic = 3' the record set is locked only when the update method is called. Other operations prior to this can still change, insert, and delete the current record.
Const adlockbatchoptimistic = 4'' records are not locked when being edited, but changes, inserts, and deletes are completed in batch mode.

Const ad1_text = & h0001
Const adcmdtable = & h0002
%>

18. The webpage will not be cached
Htm webpage
<Meta HTTP-EQUIV = "Pragma" content = "no-Cache">
<Meta HTTP-EQUIV = "cache-control" content = "no-cache, must-revalidate">
<Meta HTTP-EQUIV = "expires" content = "wed, 26 Feb 1997 08:21:57 GMT">
Or <meta HTTP-EQUIV = "expires" content = "0">
ASP Web Page
Response. expires =-1
Response. expiresabsolute = now ()-1
Response. cachecontrol = "no-Cache"
PHP webpage
Header ("expires: Mon, 26 Jul 1997 05:00:00 GMT ");
Header ("cache-control: No-cache, must-revalidate ");
Header ("Pragma: No-Cache ");
19. check whether a string is composed of digits.
<Script language = "JavaScript"> <! --
Function checknum (STR) {return Str. Match (/\ D/) = NULL}
Alert (checknum ("1232142141 "))
Alert (checknum ("123214214a1 "))
// --> </SCRIPT>

20. Get the size of a window
Document. Body. clientwidth, document. Body. clientheight

21. How can I determine whether it is a character?
If (/[^ \ x00-\ xFF]/g. test (s) Alert ("containing Chinese characters ");
Else alert ("All characters ");

22. Number of lines of textarea adaptive text
<Textarea rows = 1 name = S1 Cols = 27
Onpropertychange = "This. style. posheight = This. scrollheight">

The page is very simple. It is a text box keyword and an image button doit. The function is to click the doit image to display the search result in a new window.

I used to use the doit_click button
Response. Write ("<SCRIPT> window. Open
('Search. aspx? Keywork = "& keyword. Text &" ', _ blank) </SCRIPT> ")
The function is implemented, but it is blocked by advertisements.ProgramBlock.

Later, The onclick = "window. Open ('search. aspx ')" method was used to open it, and Session ("keyword") was used to pass parameters. However, I encountered a problem: I assigned a value to the session ("keyword") in doit_click. oncick can be executed before doit_click, that is, the new page is opened first, and the session is assigned a value, this makes the search keyword the previous keyword. And cannot solve the problem.

A:
Obtain the value of the text box in onclick and upload it as a URL parameter to search. aspx.

VaR keyword = Document. getelementbyid ('keyword ');

Window. Open ('search. aspx? Keyword = '+ encodeuri (var. Value ));

////
Q:
The error ????
Datanavigateurlformatstring = "javascript: window. Open
('Coursedetails. aspx? Coursecode = ', '', 'width = 600,
Height = 400, toolbar = 0, menubar = 0 ')"

However, after clicking the link, a window is displayed except for the desired window. The window page only contains the words [object]. The window title is javascript: window. Open ('coursedetails. aspx? Coursecode = ', '', 'width = 600, Height =...

A:
Private void projectinfo_itemdatabound (Object sender,
System. Web. UI. webcontrols. datagriditemeventargs E)
{

If (E. Item. itemtype = listitemtype. Item | E. Item. itemtype
= Listitemtype. alternatingitem)
{

// Specify the connection Field
String navigaterurl = pargeturl + "? Id = "+ E. Item. cells [1]. text;
// Customize client attributes
Stringbuilder clienttitle = new stringbuilder ();
Clienttitle. append ("This. bgcolor = '# ffefe5 '");
E. Item. Attributes. Add ("onmouseover", clienttitle. tostring ());
E. Item. Attributes. Add ("onmouseout", "This. bgcolor = '# ffff '");
// E. Item. cells [0]. Attributes. Add ("onclick", "javascript: Show ()");
E. item. attributes. add ("onclick", "javascript: window. open ('"+ navigaterurl +"', 'mainframesetmain'), this. bgcolor = '# c1d2ee '");
// Display without line breaks




}

}

///
Who helped me write a program to open a new window of 340*340 in JavaScript.

A: window. Open ('A. aspx ', '', 'toolbar, menubar, scrollbars, resizable, status,
Location, directories, copyhistory, Height = 340, width = 340 ')

Window. Open ('A. aspx ', '', 'toolbar = No, menubar = No, scrollbars = No,
Resizable = 1, location = No, status = no', Height = 340, width = 340 ');
All pop-up advertisements do this. You can see the Sina homepage.
<Script language = JavaScript>
<! -- Hide
VaR newwindow = NULL
Function windowopener (loadpos)
{
If (! Newwindow | newwindow. Closed)
{
Newwindow = Window. Open (loadpos, "surveywin", "toolbar, resizable, scrollbars,
Dependent, width = 400, Height = 280 ");
} Else
{
Newwindow. Focus ();
}
}

// End -->
</SCRIPT>

///
Q:
Ask about window. Open. After verification, I opened a new window with window. Open. How can I close the current window? Thank you! Response. write ("<script language = 'javascript '> window. open ('systemconfig/index. aspx ', '', 'width = 1012, Height = 710, Left = 0, Top = 0,
Resizable = Yes '); window. Close (); </"+" script> ");

In this case, window. Close () will pop up a prompt box prompting whether to close it. How can I close it without prompt? Or use another method. Thank you @!

A:
Window. Opener = NULL;
Window. Close ();
A2:
Response. write ("<script language = 'javascript '> window. open ('systemconfig/index. aspx ', '', 'width = 1012, Height = 710, Left = 0, Top = 0,
Resizable = Yes '); window. Opener = NULL; window. Close (); </"+" script> ");

//
open a new window, load the document specified by the URL, or load a blank document, if the URL is not provided.
applicable to
window
syntax
widow = object. open ([url [, name [, features [, replace])
parameter description
URL specifies the URL string of the document to be displayed. If the URL is specified, a new window with about: blank is displayed. Name option. Specifies the string of the window name. This name is used on form or for.. Specifies the string of the window decoration.
The following table lists the supported feature syntax description
fullscreen = {Yes | no | 1 | 0} specifies whether the browser is displayed on the full screen or in a normal window. The default value is no. Be careful when using full screen mode. This mode hides the title bar and menu of the browser. You should provide a button or other clues to help the user close the window. Alt + F4 also closes this new window.
channelmode = {Yes | no | 1 | 0} specifies whether to display the window in theater mode and display the channel band.
toolbar = {Yes | no | 1 | 0} specifies whether the browser toolbar, makingbutton, and, for example, available back, forward, stop
location = {Yes | no | 1 | 0} specifies whether to display the input field used to directly type the URL in the browser

Directories = {Yes | no | 1 | 0} specifies whether to add a directory button. The default value is no.
Status = {Yes | no | 1 | 0} specifies whether to add status bars at the bottom of the window. The default value is no.
Menubar = {Yes | no | 1 | 0} specifies whether to display the menu bar. The default value is no.
Scrollbars = {Yes | no | 1 | 0} specifies whether the horizontal and vertical scroll bars are displayed. The default value is no.
Resizeble = {Yes | no | 1 | 0} specifies whether to display a reset size handler in the corner of the window
Width = number indicates the window width, in pixels.
Height = Number specifies the window height, in pixels. The minimum value is 100
Top = Number specifies the top position in pixels. This value is relative to the upper left corner of the screen.
Left = number indicates the left position in pixels. This value is relative to the upper left corner of the screen.
Replace option. It is a Boolean value that specifies whether to create a new entry in the window browsing history or replace the current entry in the browsing history of the URL on the new page. If it is true, no new historical entries are created.

Return Value
Returns a reference to a new window.
Use this reference to script attributes and methods in the new window. It indicates that a new window name can be used as a form or a target of Element. Create a window by default using the open () method. This window has default width and height, standard menus, toolbar, and other Internet Explorer features. You can use feature parameters to change this set of features. This parameter is a string composed of one or more feature settings. Replace the parameter to control whether the new window is placed in the browser history list. As an example, create a new window with sample.htm on the bottom. The new window is 200 multiplied by 400 pixels and has a status bar, but there is no toolbar, menu, or address field.
Window. Open ("ample.html", null, "Height = 200, width = 400,
Status = Yes, toolbar = No, menubar = No, location = No ");

//// Q:
In initird, click the pop-up window on the Link field.
<Asp: hyperlinkcolumn text = "& gt; go" datanavigateurlfield = "operid" datanavigateurlformatstring = "javascript: showmodaldialog ()">
</ASP: hyperlinkcolumn>
In this way, the pop-up window can be implemented. How can I use window. Open and showmodaldialog? Then, how does one pop up a dialog box in a new window?
A:
Backend:
For (Int J = 0; j <DG. Items. Count; j ++)
{
Str1 = "mm_openbrwindow ('06digital _ view. aspx? E = '"+
DG. datakeys [J]. tostring () + ", ' ', 'width = 550, Height = 400 ')";
HLINK = (Hyperlink) DG. items [J]. cells [4]. findcontrol ("HLINK ");
Hlink. Attributes. Add ("onclick", str1 );
}

Front-end:

<Meta http-equiv = "Content-Type" content = "text/html; charset = big5">
<Script language = "JavaScript">
<! --
Function mm_openbrwindow (theurl, winname, features) {// V2.0
Window. Open (theurl, winname, features );
}

// -->
</SCRIPT>

A2:
If the pop-up window using datanavigateurlformatstring is ineffective, you can use the following methods:

<Columns>
<Asp: templatecolumn runat = "server">
<Itemtemplate> <a href = ''onclick = 'Return f_open1 ("<% #
Databinder. eval (container. dataitem, "FILENAME") %> ") '> <% #
Databinder. eval (container. dataitem, "title") %> </a>
</Itemtemplate>

<Script language = "JavaScript">
Function f_open1 (name)
{
Window. Open ('infoshow. aspx? Name = '+ name ,'',
'Scrollbars = Yes, toolbar = No, location = No, directories = No,
Status = No, menubar = No, resizable = Yes, Top = 0, Left = 0, width = 480%, Height = 400% ');
Return false;
Window. Opener = NULL;
Window. Close ();
}
</SCRIPT>

//
I wrote it in aspx, not in. CS.

<Asp: hyperlinkcolumn text = "& gt; go" navigateurl =
"Javascript: window. Open ('A. aspx? Id = <% # databinder. eval (container. dataitem, "operid") %> ', '', 'toolbar = no');"> </ASP: hyperlinkcolumn>

<Asp: hyperlinkcolumn text = "& gt; go" datanavigateurlfield = "operid" datanavigateurlformatstring = "javascript: window. Open ('A. aspx? Id = ', '', 'toolbar = no');"> </"> </ASP: hyperlinkcolumn>

/////
Use the hyperlink of the DataGrid to open the new page. How can I refresh the parent page after modifying data on the new page?
I used response. Write ("<script language = 'javascript '>
Window. Parent. Location. Reload (); </SCRIPT> ");
But not easy to use? Why?

Response. Write ("<script language = 'javascript '> self. Close (); </SCRIPT> ");
Yes!
A1:
If you use the window. open () method of JavaScript to open it, try:

Window. opener. Location. Reload ();

If you use a hyperlink <a href = "mypage. aspx "target =" _ blank "> opens in a new window </a>. Therefore, there is no relationship between the two windows. Therefore, you cannot refresh the window for opening a new page.
A2:
Use response. Write ("<script language = 'javascript '>
Window. opener. Location. href = Window. opener.
Location. href; window. Close (); </SCRIPT> ");

A2:
This is a problem ~~~~ It's actually an old problem ~~~~~

1. If your parent page has been submitted, and this page has been submitted, that is, ispostback = ture.JavascriptOf
Window. opener. Location. Reload.

2. Unless your parent form does not submit this page, it is all submitted through href =... _ blank and used in the child page
Reload () is no problem.

A3:
I have been studying this issue over the past few days. You can refresh the parent page. I used the open mode dialog box to submit and automatically close and then refresh the parent page.
Because I don't know whether the text of the "use DataGrid HYPERLINK" link is a data binding or a fixed link. The two links use different event processing modules.
Assume that your link is the third column of your DataGrid and is the modify button.CodeAs follows:

Add to HTML code:

the above JS Code calls the DataGrid Hyperlink and the parameter is the query string keyword, let editdata. aspx.

Then there is the background code:
Assume that the <asp: hyperlink) label is used, and the name is lnkedit.
First, you must add the DataGrid event handler (the DataGrid name is mydatagrid) to "initializecomponent ()" of "code generated by web forms designer ):
This. mydatagrid. itemdatabound + =
New maid (this. mydatagrid_itemdatabound );
Then vs.net will automatically generate a mydatagrid_itemcreated method, and add:

Private void mydatagrid_itemdatabound (Object sender, datagriditemeventargs E)
{
If (E. Item. itemtype = listitemtype. Item | E. Item. itemtype = listitemtype. alternatingitem)
{
For (INT I = 0; I <mydatagrid. Items. Count; I ++) // query all the rows in the DataGrid cyclically
{
Hyperlink lnk;
Lnk = (Hyperlink) mydatagrid. items [I]. cells [2]. findcontrol ("lnkedit ");
// Now, the link is found and you can add something.
// Obtain the primary key of the record first
String STR = mydatagrid. datakeys [I]. tostring ();
Lnk. navigateurl = "#"; // indicates the internal link
// Note: the following line of code calls the written JavaScript code and passes the parameters.
Lnk. Attributes. Add ("onclick", "javascript: openeditwin ('" + STR + "')");
}
}

The above method is to forcibly modify the content of the link field after the DataGrid data is bound.

The following is the content of dataedit. aspx:
This page is actually a modal dialog box, which has two difficulties:
1. Submit and open a new window automatically
2. The reference to the parent window is invalid (that is, the window. Opener operation is invalid)

Connect:
It took me a long time to solve the first problem. I found a lot of information on the Internet. The solution is nothing more than the following:
1. Add 2. Use the <IFRAME> framework in the open modal dialog box, use the. aspx file in the framework, and use the name of <IFRAME> for file submission target. That is, the modal dialog box does not directly open the. aspx file, but opens the file containing the framework and uses the aspx file in the framework.
I have used the above two methods. The first method is used. A new window is opened when the form is submitted. The second method is not available because I want to pass the query string to the file opened in the modal dialog box, and this file cannot pass the string to the file contained in the Framework.
I am still using JS scripts to solve this problem. In the modal dialog box, open the. aspx file and use. aspx normally? Add the JS Code to this. aspx file in the format of ID = xxx:
<Script language = "JavaScript">
<! --
Function onsubmit () // defines how to handle a form submission event
{
Document.form1.tar get = "_ Self ";
}
// -->
</SCRIPT>
The code above indicates that when the form is submitted, the Force submission target is the current page, that is, the dialog box is used to process the submission, rather than opening a new page. I have noticed that all modal dialog boxes that automatically open new pages are caused by the submission of bids.
Then you can add the <asp: button> Control to process database operations. After the operation is completed, write JS Code to the page, close this dialog box, and refresh the parent page, just like the post-master.
Background code
Private void btnsubmit_click (Object sender, evengargs E)
{
// Database operations
// After the operation is successful, write
Response. Write ("<script language = \" javascript \ "> \ r \ n ");
Response. Write ("<! -- \ R \ n ");
Response. Write ("If (dialogarguments! = NULL) {\ r \ n ");
// Note that the preceding dialogarguments parameter is the second parameter of showmodaldialog () on the parent page.
// Refers to the window object reference of the parent page.
Response. Write ("dialogarguments. Location. Reload (true); \ r \ n ");
// The above is the code for refreshing the parent page, which is equivalent
// Window. Location. Reload (true); Code
// Response. Write ("window. Close () ;}"); // close the dialog box
// Response. Write ("// --> \ r \ n </SCRIPT>"); // close the script block
}
The code above is the code for closing the dialog box and refreshing the parent page. This code can also be directly written to the HTML of editdata. aspx and then called in the backend CS.
Sorry, the Code is a bit wrong.
Last two lines of code
// Response. Write ("window. Close () ;}"); // close the dialog box
// Response. Write ("// --> \ r \ n </SCRIPT>"); // close the script block
Not a comment. It should be
Response. Write ("window. Close () ;}"); // close the dialog box
Response. Write ("// --> \ r \ n </SCRIPT>"); // close the script block.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.