How to get and set the image size

Source: Internet
Author: User
Tags microsoft frontpage
As we all know, a variety of Web pages are inseparable from the support of images. Images increase the vividness of Web pages and increase the size of Web pages, slowing down the download speed. How to make an image display on a page of an appropriate size becomes a mystery that cannot be solved for a moment.
Not long ago, I developed a website for teaching and research, using a news management system. In the news section on the homepage, I needed to call Image files from the database as images in the Picture News, to form a text winding form. The entire system includes news uploading, news editing, and system announcements. In the development process, I have taken into account the following factors: (1) as the website maintainer, I am not very familiar with computer operations; (2) the website layout is reasonable and the content is enriched. Therefore, for the purpose of design, the width and height of the pictures on the website page must be limited to PX, although I understand that, we can use Photoshop and other image processing software to process images in advance and then upload them to the server to achieve the same effect of homepage calling, but as a user, what I hope most is that the simpler the operation, the better, so I am determined to break this problem. After several days of fierce competition, I kept looking for ways to solve the problem and continuously testing until it was successful. So far, I have written some of my experiences for the reference of many script writers.
To enable images to be displayed in an appropriate size, it is actually a matter of narrowing down the proportion of a large image. Of course, small images cannot be enlarged and displayed on webpages; otherwise, image distortion may occur. How to obtain the image size (width, height) through the image URL is the key to the problem. I went online to search for the possibility of using javascript to write images and scale proportionally, finally, find the article "adaptive image size pop-up window". The page effect is: click the text hyperlink, a new window is displayed, showing the image. The form size is the same as the image size, in this article, javascript: Image () objects are used to dynamically load images to obtain the Image height and width, set the height and width of the pop-up window based on the height and width of the source image. The main code is as follows:
Test 1:
<Html>
<Head>
<Meta http-equiv = Content-Type content = text/html; charset = gb2312>
<Meta name = GENERATOR content = Microsoft FrontPage 4.0>
<Meta name = ProgId content = FrontPage. Editor. Document>
<Title> test </title>
</Head>
<Body>
<Script language = javascript type = text/javascript>
<! --
Var imgObj;
Function checkImg (theURL, winName ){
// Whether the object has been created
If (typeof (imgObj) = object ){
// Whether the image height and width have been obtained
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.