Asp. NET tutorials: Friendly HTML and js for SEO

Source: Internet
Author: User
Tags html page html tags net return window client

Suppose you need to move from one page to another, and there are a number of ways, how do you choose? Can you explain the reasons clearly?

<%--Link Representation--%>
<asp:hyperlink id= "HyperLink1" runat= "Server" navigateurl= "~/default2.aspx" >HyperLink</asp:HyperLink>
<asp:linkbutton id= "LinkButton1" runat= "Server" postbackurl= "~/default2.aspx" >linkbutton</asp:linkbutton >

<%--for aesthetic reasons, many websites will use button to replace link--%>
<asp:button id= "Button1" runat= "Server" text= "button" postbackurl= "~/default2.aspx"/>

<%--use the picture to make the link, also has two kinds of choice way--%>
<asp:imagebutton id= "ImageButton1" runat= "Server" postbackurl= "~/default2.aspx" imageurl= "~/upup.gif"/>
<asp:hyperlink id= "HYPERLINK2" runat= "Server" navigateurl= "~/default2.aspx" imageurl= "~/upup.gif" ></asp: Hyperlink>

If you're still confused, I suggest you look at the source code after they generate HTML.

<a id= "HyperLink1" href= "default2.aspx" >HyperLink</a>
<%--hyperlink parsed into HTML corresponds to a simple hyperlink, href points to the page to jump--%>

<a id= "LinkButton1" href= "Javascript:webform_dopostbackwithoptions" (New Webform_postbackoptions, "LinkButton1", " ", False," "," default2.aspx ", False, True)" >LinkButton</a>
<%--linkbutton1 is also an anchor tag, but is actually using JavaScript to make a jump--%>

<input type= "Submit" Name= "Button1" value= "button" onclick= "Javascript:webform_dopostbackwithoptions" (New WebForm _postbackoptions ("Button1", "", False, "", "default2.aspx", False, False)) "Id= Button1"/>
<%--button is parsed into the input element of the type= "submit", which also jumps through the JavaScript page--%>

<input type= "image" Name= "ImageButton1" id= "ImageButton1" src= "Upup.gif" onclick= "Javascript:webform_" Dopostbackwithoptions (New Webform_postbackoptions ("ImageButton1", "", False, "", "default2.aspx", False, False)) " Style= "border-width:0px;"/>
<%--imagebutton is parsed into type= "image" input elements, as well as page jumps through JavaScript--%>

<a id= "HyperLink2" href= "default2.aspx" ></a>
<%--to the Hyperlink ImageUrl property, after parsing into HTML corresponds to a HYPERLINK "clip" an IMG, but the page that href still points to to jump--%>

What's the use of knowing this?

Useful, but today we are only talking about SEO.

In the current search engine technology, JavaScript (including Ajax, of course), form elements (such as input), Flash, and image are not (or can be) read. "Spiders" tend to read text in simple HTML format. So, from the point of view of SEO:

1. Do not use JavaScript or form for page jump links, if a normal <a></a> can do the same function. In general, any navigation that cannot pass the standard anchor identifier <a></a> entry is not retrieved by spiders. We should be more aware of this if we were using the client element, but we might be careless when we use a server-side control that is encapsulated and processed.

2. Note that there is no textual content in the UpdatePanel. We can do a simple test:

<asp:scriptmanager id= "ScriptManager1" runat= "Server" >
</asp:ScriptManager>
<asp:updatepanel id= "UpdatePanel1" runat= "Server" >
<ContentTemplate>
<asp:label runat= "Server" id= "LBL" ></asp:Label>
<asp:button id= "Button1" runat= "Server" text= "button" onclick= "Button1_Click"/>
</ContentTemplate>
</asp:UpdatePanel>

protected void Button1_Click (object sender, EventArgs e)
{
This.lbl.Text = "I was created by UpdatePanel, so you can't see me!" ";
}

Part of the source code after parsing into HTML:

<div id= "UpdatePanel1" >
<span id= "LBL" ></span>
<input type= "Submit" Name= "Button1" value= "button" id= "Submit1"/>
</div>

This is well understood, because UpdatePanel is the same as using the page's JavaScript function to generate page content. Looking at the source code, we can see the relevant JavaScript functions, but we can't see what the function generates. and the search engine spider, it is only to see the source code.

3. When we need to use a pop-up page, the usual practice is:

<a href= "#" onclick= "window.open (' popup.html ', ' common ', ' height=600,weight=800 ');" >common popup</a>

According to our above explanation, this kind of writing, for SEO, is undoubtedly unfavorable. So we should use the following code, that is, to ensure the effect of pop-up window, but also SEO friendly. And even if the client's browser does not support or disable JavaScript, the page can jump smoothly.

<a href= "popup.html" onclick= window.open (this.href, ' seo ', ' height=600,weight=800 '); return false; "Target=" _ Blank ">seo popup</a>
<%--Note: The return false statement here cannot be omitted. --%>

4. When we want to use a special font (often the title of the column), we often use a picture of Chinese characters instead. This is also a more troublesome thing, because as a title, its content is often very important keywords, if the use of pictures, spiders can not read. One possible solution is SIFR, but I'm not very familiar with it; it doesn't seem to be applied to Chinese characters.

For pictures, our common SEO method is to indicate title and ALT, as

But this also belongs to "invisible page element", the concrete effect how also difficult to measure accurately. But there's always better than nothing!

5. Other Considerations:

5.1 combines the semantics of HTML tags with CSS, and "span" and "div" different, "H1" means that the title, "B" means that the emphasis, "ul" "Li" means that the list ..., these semantic tags can give the search engine clearer instructions;

5.3 Important content on the top of the HTML page (referring to the source code, not the browser display result)

5.5 The large section of JavaScript on the bottom of the page or a separate JS file;

5.2 It is best not to use frames (frame) layout;

5.3 A large number of ViewState may cause interference to the "spider";

5.5 Keep in mind: in the current search engine technology, JavaScript (including Ajax, of course), form elements (such as input), Flash, and image are not (or can be) read.

Author: free Flying http://www.cnblogs.com/freeflying/archive/2010/02/19/1669469.html



Related Article

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.