


Javascript implements the effect of uploading pictures and previewing code_javascript skills
Today, the src attribute of the alphaimageloader filter is the protagonist. It uses an absolute or relative url address to specify the background image. If this parameter is omitted, the filter will have no effect.
Select picture:
Example 2. At the same time Compatible with ie6, ie7, ie8 and firefox.
"http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<script> <br>var picpath; <br>var image; <br>// preview picture <br>function preview() <br>{ <br>document.getelementbyid('preview').style.display = 'none'; <br>// The following code is used to obtain the image size so that the image can be displayed normally under IE <br>document.getelementbyid('box' ).innerhtml <br>= "<img width='" image.width "' height='" image.height "' id='apic' src='" picpath "'>"; <br>} <br>// show view button <br>function buttonshow() <br>{ <br>/* <br>This is used to solve the preview failure caused by image loading delay. <br>A brief explanation, when the image object When the src attribute changes, JavaScript will reload the image content to the image. <br>This usually takes some time. If you want to display the image before the loading is completed, it will cause an error, so we <br>pass the width and width of the image. height to determine whether the image has been loaded successfully, and the preview button will be displayed only after the loading is completed. <br>I still have a confusion here, the preview effect occasionally fails under IE7. <br>*/ <br>if ( image.width == 0 || image.height == 0 ) { <br>settimeout(buttonshow, 1000); <br>} else { <br>document.getelementbyid('preview').style.display = 'block'; <br>} <br>} <br>function loadimage(ele) { <br>picpath = getpath(ele); <br>image = new image(); <br>image.src = picpath; <br>settimeout( buttonshow, 1000); <br>} <br>function getpath(obj) <br>{ <br>if(obj) <br>{ <br>//ie <br>if (window.navigator.useragent.indexof ("msie")>=1) <br>{ <br>obj.select(); <br>// Get the local path of the image under ie <br>return document.selection.createrange().text; <br>} <br>//firefox <br>else if(window.navigator.useragent.indexof("firefox")>=1) <br>{ <br>if(obj.files) <br>{ <br>// What is obtained under firefox is the image data <br>return obj.files.item(0).getasdataurl(); <br>} <br>return obj.value; <br>} <br>return obj .value; <br>} <br>} <br></script>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to implement image scrolling and thumbnail preview in Vue? In Vue projects, we often need to display a large number of pictures, and hope that users can browse and preview these pictures easily. This article will introduce how to use Vue components to implement image scrolling and thumbnail preview functions. First, we need to install and introduce the appropriate Vue library to facilitate image scrolling and thumbnail preview. In this example, we will use vue-awesome-swiper and vue-image-preview two libraries to implement

As one of the most popular short video sharing platforms in the world, Douyin has attracted hundreds of millions of users to join it. When looking at other people's wonderful works, we are often moved by some dynamic, interesting or meaningful moments in them. At this time, we can not only express our opinions and thoughts through text comments, but also express our emotions more vividly through picture comments. So, how to post picture comments on TikTok? First, open the Douyin APP and enter the video you are interested in. Next, we need to determine the operating system of the mobile phone according to the different

Apple today released Safari Technology Preview version 173, which covers some features that may be launched in Safari 17. This version is suitable for macOS Sonoma beta version and macOS Ventura system. Interested users can download it from the official website. Safari Technology Preview version 173 adds a feature flag block in settings, replacing the experimental feature in the original development menu. This section allows developers to quickly search for specific features and marks the status as "stable", "available for testing", "preview" or "developer" in different ways. The redesigned development menu makes it easier for creators to find key tools for building web pages, web apps, web content in other apps,

How to implement form image upload and preview in Vue form processing Introduction: In modern web applications, form processing is a very common requirement. One common requirement is to allow users to upload images and preview them in a form. As a front-end framework, Vue.js provides us with a wealth of tools and methods to achieve this requirement. In this article, I will show you how to implement image upload and preview functions in Vue form processing. Step 1: Define Vue components First, we need to define a Vue group

How to upload and preview images through Vue? Overview: In modern web applications, image uploading and previewing are a common requirement. Vue, as a popular JavaScript framework, provides a convenient way to achieve this function. This article will introduce how to use Vue to upload and preview images, including the design of the front-end interface and the processing of the back-end interface. Front-end interface design: First, we need to design a front-end interface to select and upload images. In Vue, we can use <i

How to implement image upload and preview in uniapp In modern social network and e-commerce applications, image upload and preview functions are very common requirements. This article will introduce how to implement the image upload and preview functions in uniapp, and give specific code examples. 1. Implementation of the image upload function In the uniapp project, you first need to add an image upload component to the page, as shown below: <template><view><im

Solution to the problem that everything cannot be displayed when previewing and printing: 1. Open the WPS Office form and click "Print Preview" in the upper left corner of the workbar area; 2. Enter the print preview page and click "Scale Ratio"; 3. In the drop-down list that appears Select the applicable ratio from "Landscape" or "Portrait".

We can update and upgrade the windows 11 system in the preview program of the windows system, but many friends have encountered the error code 0x0 when joining the preview program. This is because our system is missing part of the registry. You can re-export it. To solve it, let’s take a look at it together. How to deal with errors in the win11 preview program. Method 1: 1. If our system is not the latest version of the system, we can try to update it in the system update. Method 2: 1. The error may also be a problem with the registry. We can try to use the registry repair tool to repair it. Method three: 1. Download the win11 system directly from this site and install it. 2. After downloading, just install it according to the tutorial provided on this site.
