×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    7

    Question Home Screen Widget Problem

    Hello,

    I had made a simply Home Screen Widget as these codes:

    index.html

    <html>
    <head>
    <title>Sample Widget</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script language="javascript" type="text/javascript" src="basic.js">
    </script>
    <style type="text/css">
    @import "basic.css";
    </style>
    </head>
    <body id="body" onload="setViewMode();" onshow="setViewMode();" onresize="setViewMode();">
    <div id="main"></div>
    <div id="mini"></div>
    </html>

    basic.js
    function setViewMode(){
    var isInHSView = isHSViewMode();
    if (isInHSView) {
    //initHomeScreen();
    document.getElementById("mini").innerHTML = "Mini View";
    }
    else {
    //initFull();
    // hide config view
    document.getElementById("main").innerHTML = "Main View";
    }
    }

    isHSViewMode: function(){
    alert("hs view mode");
    var size = this.getScreenSize();
    return (size.height < HS_VIEW_TRESHOLD);
    }


    HS_VIEW_TRESHOLD = 150;


    But it does not show like what I want (Home Screen will show the text "Mini View" and Full Screen will show the text "Main View" ). Unfortunately it just shows white screen. Can anybody know why? Please help me.

    Thank you very much.

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Home Screen Widget Problem

    Hi,

    you have a syntax error in your JavaScript code.

    Just replace this line:
    Code:
    isHSViewMode: function(){
    with this:
    Code:
    function isHSViewMode(){
    and it should go.

    Hope it helps,
    Pit

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    5

    Re: Home Screen Widget Problem

    Hi all,

    I have the same issue.

    This page is not clear : Web Developer's Library 1.5 > Web Runtime widgets > Home screen widgets > Developing home screen widgets > Determining whether to display home screen or full screen.

    What does "this" reference when calling this.getScreenSize() ?

    Looking at STEW example, the method "isMiniViewMode" should be added in a Helper.js class file. "this" is in this case the helper class, that would contain a getScreenSize() method.

    Anyone could clarify that ?

    Thanks a lot.

    ---------------------------------

    I found the getScreenSize in the STEW example. getScreenSize's code is there. And the wiki home screen doc page should be fixed with a working full piece of code (not using the helper for instance)

    var Helper = {
    ...
    getScreenSize: function () {
    var height = window.innerHeight;
    var width = window.innerWidth;

    return {
    width: width,
    height: height
    };
    },
    ...
    }
    Last edited by mleddet; 2009-05-13 at 15:35. Reason: Solved my problem

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Home Screen Widget Problem

    Hi mleddet,

    you're right, thank you for the hint, I didn't notice the call to Helper getScreenSize() method, that should be also added to quangtrung89's code to make it work.
    Code:
    function  getScreenSize()
    {
    	var height = window.innerHeight;
    	var width = window.innerWidth;
    
    	return {
    		width: width,
    		height: height
    	};
    }
    Pit

Similar Threads

  1. Question about new home screen widgets
    By wturnage in forum Symbian Web Runtime
    Replies: 8
    Last Post: 2010-01-25, 10:14
  2. Hide or Home Screen App id
    By idokd in forum Symbian Web Runtime
    Replies: 3
    Last Post: 2009-01-17, 10:14
  3. Display of town names or landmarks on home screen
    By psdeepti in forum Symbian C++
    Replies: 0
    Last Post: 2007-12-13, 15:32
  4. screen rotation problem
    By davidmaxwaterman in forum Symbian C++
    Replies: 0
    Last Post: 2007-10-12, 06:29
  5. help:nokia7610 screen problem!
    By superpi in forum General Development Questions
    Replies: 1
    Last Post: 2005-08-29, 18:26

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •