facebook

Change background image: CLOSED

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #327284 Reply

    Yann
    Member

    Hello,
    i don’t understand why my script do not run

    phoneui.postOrientationChange = function(newOrientation) 
      {
       if(newOrientation==0)
        {
    
        $("m1-index-background").attr("src","images/640x960-portrait");
        }
          else
          {
          $("m1-index-background").attr("src","images/640x960-paysage");
      }
    }

    any idea?
    thanks
    Yann

    Closed i found the problem

    #327339 Reply

    Yann
    Member

    up

    #327340 Reply

    support-michael
    Keymaster

    @Yann

    When your custom javascript fails to run in almost all cases there is an error in your code. Did you find the issue, e.g., syntax error in your snippet such as missing closing brace }

    When in doubt run the design in the Test Center and then open the Tools Panel. Navigate to the JavaScript debugger and select the xxx_custom.js file. It will load and identify syntax error. If no syntax error then set a breakpoint in a line before you code. Then step through your code and monitor the state of variable and execution. I use this approach all the time when debugging user’s code. I would be dead without the debugger.

    #327341 Reply

    Yann
    Member

    Thanks Wayne
    yes i had an error in my code, now i looking for how add size image in this code
    $(myimg).attr(“src”,”images/ardoise.png”);
    in landscape mode my image is larger than portrait mode
    thanks
    Yann

    #327355 Reply

    @Yann,

    Try with next code:

    $(image).height(newheigth);
    #327780 Reply

    Yann
    Member

    Hello
    i try this without success
    if(newOrientation==0)
    {
    $(‘body’).css(‘background-image’, ‘url(“images/fond-portrait-640×960.jpg”)’);

    }
    else
    {
    $(‘body’).css(‘background-image’, ‘url(“images/fond-landscape-640×960.jpg”)’);

    }
    how i can apply a background image and change it when orientation change?
    thanks

    #327850 Reply

    Hi Yann,

    Please try the next code:

    
    if(newOrientation==-90||newOrientation==90){
      $('#m1-projectname').css('background-image', 'url("images/fond-landscape-640x960.jpg")');
    }
    else{
      $('#m1-projectname').css('background-image', 'url("images/fond-portrait-640x960.jpg")');
    }
    #327861 Reply

    Yann
    Member

    Hello Octavio
    thanks a lot, this function run as well.

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: Change background image: CLOSED

You must be logged in to post in the forum log in