JavaScript gets all the pictures of the document

Source: Internet
Author: User
Tags assert manual goto static class tagname ssis

JavaScript gets all the pictures of the document
function UpdateUI () {
var IMGs = document.getelementsbytagname ("img");
For (Var i=0, len=imgs.length i < Len; i++) {
Imgs[i].title = Document.title + "image" + i;
}

var msg = document.getElementById ("msg");
msg.innerhtml = "Update complete."
}

This function may seem completely fine, but it has three reference global document objects. If there is a large number of images on a page, the circular reference file can be executed dozens of or hundreds of times each time you need to find the range chain. By creating a local variable for the Document object point, you can increase the limit of some global lookups with only one performance of this function:

function UpdateUI () {
var doc = document;
var IMGs = doc.getelementsbytagname ("img");
For (Var i=0, len=imgs.length i < Len; i++) {
Imgs[i].title = Doc.title + "image" + i;
}

Here, the first document object is stored in the local document variable. The document variable, and then use the file location in the rest of the entire code. Only one global lookup in this function, compared to previous versions, guaranteed that it would run faster. A good rule of thumb is any global storage object that is used more than once as a local variable in a function.

Avoidance and declaration


The WITH statement should be avoided when performance is important. A similar feature that has a statement to create its own scope, thus increasing the length of the chain it executes in the scope of the code. The execution of the code in the statement is to ensure that the code runs faster than the execution because of the extra steps in the lookup range chain. This is a rare statement that is required because it is mainly used to eliminate extra characters. In most cases, local variables can be used to accomplish the same thing without introducing a new range. Here is an example:

function Updatebody () {
With (Document.body) {
alert (tagName);
InnerHTML = "Hello world!";
}
}

function Updatebody () {
var BODY = Document.body
alert (body.tagname);
body.innerhtml = "Hello world!";
}

This code uses Document.body to make it easier to speak with. The same effect can be achieved by using a local variable, as follows:
var msg = Doc.getelementbyid ("msg");
msg.innerhtml = "Update complete."
}

ASP.net UI tool test

When you test the user interface, you are testing human activity. Because of this, you should let the computer perform the task is very good, you should perform the type of task, you are easy to mess with. When developers and testers first learn about the UI tools that are available for testing, they tend to think that everything can be automated, which is far from reality. 7th chapter of the book's Test asp.net Web application [, by Jeff McWherter and the Department (ISBN: 978-0-470-49664-0,wrox Press, 2009, Copyright Wiley Publishing Company)] about in-depth talks, manual tests but now it's important that we understand that Manual testing is still a very important test discipline for a test cycle.

Professor Frederick Brucks in the title "No silver bullet-nature and software engineering accident," 1987 software Developer's file, no silver bullet in software development, which means that there is no tool that can solve the whole work you want to accomplish. Interface testing should not be considered final for all upcoming tests. When the user interface is properly tested, it is a very powerful test tool.

Before you realize the importance of user interface Automation testing, the next most important decision to make is that your tool will use the created test. There are three schools of thought how to test the user interface.

Analog browsers

This is a headless set of scripts sent by a request to simulate the same type of browser, but the response time of the measure, rather than the content expression, is sent back. This type of UI test is great for discovering bottlenecks in Web applications. The disadvantage of this type of test is that you are not studying and verifying the reaction of the test. This type of test can only be used for volume, pressure, and load test scenarios.

The Network Capacity Analysis tool (cold atom capture) is a lightweight HTTP load generation tool designed to simulate the number of concurrent users, requesting a site. Cold atom capture with simple script to simulate a browser and fully exercise a website:

A new deal.

The CLASSID = 1

HTTP for new request

verb = "get"

url = "http://www.google.com"
Using Nunit.framework;

Using System.Net;

Using System.IO;

Namespace Parsehttp

{

[Testfixture]

public class Parsehttp

{

[Test]

public void Should_navigate_to_google_and_return_results_for_aspnet ()

{

String urltotest =

"Http://www.google.com/search?hl=en&rlz=1G1GGLQ_ENUS295&q=asp.net&btnG=Search";

string result = GetPage (urltotest);

Assert.istrue (result. IndexOf ("the official") >0, "asp.net Page");

}

private string GetPage (String urltotest)

{

Create a Web client object to load the page from local server

WebClient client = new WebClient ();

string result = String. Empty;

Dump the contents of the page we navigated to into a stream

using (StreamReader reader = new

StreamReader (client. OpenRead (Urltotest))

{

result = reader. ReadToEnd ();

}

return result;

}

}

}

Browser

In this interface test method (such as the future listing), the test will open a physical browser, perform the behavior, and then the test will validate your input in the test based HTML. This automatic interface test type is a manual test closest to what you will get. Because the test needs to open the browser, execute the test, and report that the results support this type of test is very fragile. These types of tests are often complex, and if your plan is only to stress test your application This type of test will be overkill:


Using Nunit.framework;

Using Watin.core;

Using WatiN.Core.Interfaces;

Namespace Simplewatintest

{

[Testfixture]

public class Simplewatintests

{

[Test]

public void Should_click_search_on_google_and_return_results_for_aspnet ()

{

using (Ibrowser ie =

Browserfactory.create (Browsertype.internetexplorer))

{

Ie. GoTo ("http://www.google.com");

Ie. TextField (Find.byname ("Q")). Value = "asp.net";

Ie. Button (Find.byname ("btng")). Click ();

Assert.istrue (ie. ContainsText

("The official Microsoft asp.net Site");

}

}

}

}

Using Nunit.framework;

Using Watin.core;

Using WatiN.Core.Interfaces;

Namespace Simplewatintest

{

[Testfixture]

public class Simplewatintests

{

[Test]

public void Should_click_search_on_google_and_return_results_for_aspnet ()

{

using (Ibrowser ie =

Browserfactory.create (Browsertype.internetexplorer))

{

Ie. GoTo ("http://www.google.com");

Ie. TextField (Find.byname ("Q")). Value = "asp.net";

Ie. Button (Find.byname ("btng")). Click ();

Assert.istrue (ie. ContainsText

("The official Microsoft asp.net Site");

}

}

}

}

Below is a table of how-HTML elements can be obtained using the Watin framework. Watin HTML Mapping:

HTML ELEMENT watin Class Example
<a/> Link Ie.link (LinkId)
<button/> Button Ie.button (buttonid)
<div/> Div ie.div (divid)

<form/> Form Ie.form (formid)
<frame/> Frame
Ie.frame (Frameid)
<iframe/> Frame ie.frame (Iframeid)
Image ie.image (imageID)
<input type=button/> button Ie.button (ButtonID)
<input type=checkbox/> checkbox Ie.checkbox (CHECKBOXID)
<input type=file/> fileupload ie.fileupload (Fileuploadid)
<input type=image/> Image Ie.image (imageID)
<input type=password/> TextField Ie.textfield (Passwordid)
<input type=radio/> RadioButton Ie.radiobutton (radioid)
<input type=submit/> Button Ie.button (Submitid)
<input type=text/> TextField Ie.textfield (Textid)
<label/> Label
Ie.label (ElementID)
<option/> Option Ie.select (Selectid). Options
<p/> Para Ie.para (pId)
<select/> Select Ie.select (selectid)
<span/>
<table/> Table ie.table (tableId)
<tbody/> tablebody ie.tablebody (Tablebodyid)
Ie.table (TableID). Tablebodies
<td/> TableCell Ie.tablecell (tablecellid)
Ie.table (TableId). Tablerows[0]. Tablecells[0]
<textarea/> TextField Ie.textfield (textareaid)
<tr/> TableRow ie.tablerow (tablerowid)
Ie.table (TableId). Tablerows[0]
All elements, also the ones is not mentioned in this list Element and
Elementscontainer ie.element (ElementID)
Ie.element (tagname, ElementID)

Java Online Photo code

The popularity of digital cameras (especially on phone phones) has led to their falling prices as much as their size has shrunk. It is now becoming harder to find, even without the camera's phone, and robotic devices are no exception. To access the camera's hardware, you need to add the list of licensed applications to your camera, as follows:


<uses-permission android:name= "Android.permission.CAMERA"/>

This grants access to the camera service. The camera class can adjust camera settings, take photos, camera and process streaming media previews. To access the camera service, use the open method of the camera's static class. When your application is with the camera, remember to call after the release of the simple use pattern code snippet that shows you the service:

Camera Camera = Camera.open ();
[ ... Do things with the camera ...]
Camera.release ();
Control camera settings


The current camera settings can be used as camera.parameters objects. Call the camera's GetParameters method to access the current parameters. You can modify the settings using the parameter * method that is set on the return. To apply the changes, please setparameters, as the revised value of the inheritance is as follows:


Camera.parameters Parameters = Camera.getparameters ();
Parameters.setpictureformat (Pixelformat.jpeg);
Camera.setparameters (parameters);

The camera's parameters can be used to specify the picture and preview size, image format, and preview frame rate.

Use Camera Preview

Streaming video into the camera means you can merge into the live video. The most exciting early robots apply some of the practical basics of enrichment, this functionality. The camera can display previews in real time to a surface, as shown in the following code fragment:

Camera.setpreviewdisplay (Mysurface);
Camera.startpreview ();
[ ... ]
Camera.stoppreview ();

You will learn more about the surface of the next chapter, although the robot includes a good example of using Surfaceview to display a real-time camera preview. This example can be shown in graphics/Camerapreview in the SDK API demo project.

You can also specify a previewcallback to be fired each preview box, allowing you to manipulate or display each individual frame preview. Call the object's camera Setpreviewcallback method, and the execution of the Onpreviewframe method pass in the new Previewcallback is as follows:

Camera.setpreviewcallback (New Previewcallback () {

public void Onpreviewframe (byte[] _data, Camera _camera) {
TODO do something with the preview image.
}
});

A camera object takepicture a picture, in Shuttercallback and RAW and JPEG picturecallback implemented through encoded images. Each picture callback will receive an array of bytes representing the image in the appropriate format, while the shutter callback triggers the shutter to close immediately after

private void Takepicture () {
Camera.takepicture (Shuttercallback, Rawcallback, Jpegcallback);
}

Shuttercallback shuttercallback = new Shuttercallback () {
public void Onshutter () {
TODO do something the shutter closes.
}
};

Picturecallback rawcallback = new Picturecallback () {
public void Onpicturetaken (byte[] _data, Camera _camera) {
TODO do something with the image RAW data.
}
};

Picturecallback jpegcallback = new Picturecallback () {
public void Onpicturetaken (byte[] _data, Camera _camera) {
TODO do something with the image JPEG data.
}
};


asp.net in SQL Server 2008 set up services (SSIS)

The

Script task allows you to access Microsoft visual for the application (VSTA version) Studio tool environment, writing and executing scripts using the VB and C # languages. The environment in China Engine is the latest version of the new SSIS, replacing the Visual Studio (VSA) environment from the 2005 version of the application. The script is now almost inappropriate because the latest version of SSIS consolidates the connection to full. For VB and C#net Library. Recently, in addition to the general Chinese environment and scripting tasks SSIS also provide these additional functional advantages:
 
  
A Smart Advantage coding environment
an integrated Visual Studio design environment SSIS
A A use method that is easy to pass to script parameters
the speed advantage of a script that can be added to your code to test and debug breakpoints (only one Script task per package)
is automatically compiled into a binary format (this is configured in an earlier version of SSIS.)
The Script task is passed in the Configure Script Task Editor Script tab (shown in Figure 3-6).
 

Figure 3-6
 
The ScriptLanguage property is the one you selected. NET language you, like to use in the task gratified. Note that the default language is set to C #, so if you are coding vb.net, don, through these settings, set your Script task under the AOT wizards. If you do anything with the previous version of SSIS development, you?? ll also notes that the Precompilescriptintobinarycode attribute has been permanently deleted. As a result, all script code is automatically compiled and persisted to the package. This speed, and reduce the run-time error of the task significantly.
 
enables you to provide a Scriptmain class instantiation at the start of another function call for the EntryPoint property. Usually, you,?? ll leave this set to the default main () function. The ReadOnlyVariables and Readwritevariables properties allow you to pass to a variable that is a comma-delimited variable name listing script SSIS. The name of the typing variable, is a small SSIS in the earlier version of the unconventional, but the latest version provides the ability to browse to the variable collection and selection of variables. Having these variables provides an important advantage of coding. All you need to mention is the ordinal position or the name of the variable set to which they can access the lock worry not to worry about their values, unlock, or block the variables in the read-write operation. You just make sure there are variables you want to write back in Readwritevariables property, or you,?? ll get a bug in the script.
 
There is also a change in the variable Allen under which the AOT Setup process provides an alternative method of presenting scripts in the 9th chapter. When you click the button to manipulate the editing script, the Visual Studio tool environment for the application is open, allowing the encoding class to be scriptmain directly. In this IDE, you can access all the advanced debugging policies, breakpoints, and IntelliSense in the Visual Studio environment. If you create a variable containing the string "Hello world" and set as shown in Figure 3-7, the following sample Script task MyValue A package that tells you how to write code, using the passed-in myvalue variable:


Publicvoid Main ()
{
if (Dts.Variables.Contains ("User::myvalue"))
{
System.Windows.Forms.MessageBox.Show ("myvalue=" + dts.variables
["User::myvalue"]. Value.tostring ());
}

Dts.taskresult = (int) scriptresults.success;
}

VBnet Code:
Publicsub Main ()
If Dts.Variables.Contains ("user::myvalue") = Truethen
System.Windows.Forms.MessageBox.Show ("myvalue=" & Dts.variables
("User::myvalue"). Value.tostring ())
EndIf

Dts.taskresult = scriptresults.success
Endsub


asp.net AJAX in asp.net 3.5 and Visual Studio 2008


Prior to this, the visual Studio 2008,asp.net Ajax product was once a standalone installation that you need to install on your machine and Web server that you are using. This version has been quickly popularized and is now part of the visual Studio 2008 product. Not only is it a part of the visual Studio 2008 IDE, the asp.net ajax product is also baked. NET Framework 3.5. This means that to use ASP.net AJAX, you do not need to install any software if you are working with ASP.net 3.5.

asp.net Ajax is now just part of the ASP.net framework. When you create a new Web application, you do not have to create a different type of asp.net application. Instead, all of the ASP.net applications created, you are now Ajax.

If you have already used ASP.net ajax to work on this previous 3.5 version, you will find that there is really nothing new to learn. The entire technology integrates seamlessly into the overall development experience.

Overall, Microsoft has been fully integrated into the entire ASP.net Ajax experience, making it easy for you to use Visual Studio and its visual design, with your AJAX-enabled Web pages, and even have complete debugging stories that you will be willing to work with with your application. Using Visual Studio 2008, you can now debug the JavaScript that you are using on the page.

In addition, it is important to highlight the compatibility of Microsoft's Cross-platform platform with ASP.net ajax. You will find that AJAX applications that you call for. NET Framework 3.5 can be built in all major growth levels of browsers themselves (such as Firefox and Opera).

Using ASP.net ajax development
There are many types of web developer couples out there. There are networks who are used to develop these controls with ASP.net and who have experience working with server-side control and manipulation of the server side. There are also some developers who focus on client and DHTML and JavaScript work to manipulate and control the pages and their behavior.

That said, it is important to realize that ASP.net Ajax is designed for two types of development. If you want to work on the server, more asp.net ajax side, you can use the new ScriptManager controls and new UpdatePanel controls to Ajax to enable you to do some work with your current asp.net application. All of this work can be done using the same programming model that you are familiar with in asp.net.

Conversely, you can also use the client script library directly to get a larger control of what is happening to the client machine. Next, this article will focus on building a simple Web application using the user's Ajax.

asp.net ajax Applications
The next step is to build a basic sample to take advantage of this new framework. Start by creating a new Web Site dialog that is used by the new ASP.net Web site application. Name the project Ajaxwebsite. You will find (Figure 1 below) that there is no ASP.net project to build a asp.net ajax application because each ASP.net application that you are now building a standalone type is Ajax.


Figure 1
When you create an application, you will see a standard Web site project now. However, you may notice that the Web.config file is the new ASP.net 3.5 some additional settings. At the top of the Web.config file, there is a new configuration, registration section, responsible for handling with Ajax. Listing 1 is presented in the web.config of this section

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.