简体   繁体   中英

How to change background image every click in windows 8 javascript

I am working on a Windows 8 metro application. In my default.html file I have a background image:

<div id="backgroundImage" >
        <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
            <defs>
                <filter id="myGaussianBlur" x="0" y="0">
                    <feGaussianBlur in="SourceGraphic" stdDeviation="2"></feGaussianBlur>
                </filter>
            </defs>
            <image xlink:href="**surf.jpg**" width="100%" height="100%" preserveAspectRatio="none" filter="url(#myGaussianBlur)" />
        </svg>
    </div>

I would like to replace the href="surf.jpg" reference. I have one more file, Creator.js , that holds the current image:

 var ControlConstructor = WinJS.UI.Pages.define("Creator.html", {
    // This function is called whenever a user navigates to this page. It
    // populates the page elements with the app's data.
    ready: function (element, options) {
        // TODO: Initialize the page here.

        // the options of the Creator are: image.
        // image is the path to the boleh creator's background image.
        options = options || {};
        this._data = WinJS.Binding.as({ image: options.image });

and I have also a getter and a setter:

 // Getters/setters for image


   image: {
        get: function () { return this._data.image; },
        set: function (value) { this._data.image = value; }
    }

i found out while i was trying to develop an app there was code write Blog reader using JavaScript.....I am sharing the link you can check if it helps you in any way.

http://msdn.microsoft.com/en-us/library/windows/apps/hh974582.aspx

You can also check a simple article that is there in Codeproject.....This can also help you http://www.codeproject.com/Articles/338916/Windows-8-JavaScript-Metro-Application-Getting-Sta

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM