- This topic has 7 replies, 3 voices, and was last updated 13 years ago by
Yann.
-
AuthorPosts
-
YannMemberHello,
i don’t understand why my script do not runphoneui.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
YannClosed i found the problem
June 20, 2012 at 8:45 am #327339
YannMemberup
June 20, 2012 at 8:59 am #327340
support-michaelKeymasterWhen 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.
June 20, 2012 at 9:12 am #327341
YannMemberThanks 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
YannJune 20, 2012 at 12:18 pm #327355
support-octavioMemberJuly 2, 2012 at 5:02 am #327780
YannMemberHello
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?
thanksJuly 3, 2012 at 5:14 pm #327850
support-octavioMemberHi 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")'); }
July 4, 2012 at 2:24 am #327861
YannMemberHello Octavio
thanks a lot, this function run as well. -
AuthorPosts