语言

Menu
Sites
Language
The alert() popup displaying and transparent background setting for the web view of native app

Hi~

I'm developing a 2.4 native application with web view (ewk_view_app) to show a web page on it.

The web page loading and page navigating are working fine with webview, but a popup window is not showing when the JavaScript alert() is invoked by a interaction on the web page.

Do I have to do something to show the popup window that is triggered by the alert() in the web page of webview?

 

Also, in case of transparent backgound web page, the web page is shown with white background in the webview.

Is there any optional method to show the transparent background web page properly in the web view?

 

I would appreciate any ideas.

Thanks in advance.

响应

9 回复
Alex Dem

Hi,
fyi, I tried to load into WebView inside Native app html page located onto local file system.

ewk_view_url_set(window->ewk_view,"file:///opt/usr/media/index.html");

(privilege http://tizen.org/privilege/mediastorage was added in my manifest).

Alert is shown on load this page. 
Code for alert inside html is:

<body onload="alert(1);">
...
</body>

I have used 2.3.1 SDK and Z1 device.
I' ll try to check onto Z3 the same code.
Alexey.

cs k

Thank you.

I've tried to make new project to verify the webview's behavior on the Z3.

I created new mobile 2.4 native project based on BasicUIApplication sample code.

And I added below codes to show the web view on the appliation GUI with sample html page that is including alert(); invocation.

but I couldn't see the alert window in the application on the Z3.

Because I'm not good at the EFL, I curious that I'm using the evas_object_evas_get() function properly...

Would you check my code whether it is fine?

 

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

native code

 

static void
create_base_gui(appdata_s *ad)
{

...

   /* Show window after base gui is set up */
    evas_object_show(ad->win);

    {
        Evas *evas = evas_object_evas_get(ad->win);
        ad->ewk_view = ewk_view_add(evas);

        Ewk_Settings* settings = ewk_view_settings_get(ad->ewk_view);
        ewk_settings_javascript_enabled_set(settings, true);
        ewk_settings_scripts_can_open_windows_set(settings, true);

        evas_object_resize(ad->ewk_view, 400, 400);
        evas_object_move(ad->ewk_view, 10,10);
        evas_object_show(ad->ewk_view);

        char path[1024] = {0,};
        snprintf(path, 1024 - 1, "file://%spopup.html", app_get_resource_path());
        dlog_print(DLOG_INFO, "swap", "path = %s", path);
        ewk_view_url_set(ad->ewk_view, path);
    }

}

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

sample html code

<html>
<head>
<script>
window.onload = function() {
    alert("onload");
};
</script>
</head>
<body>
popup test
</body>
</html>

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

* I added all recommended priviledges in below page.

https://developer.tizen.org/development/tutorials/native-application/web#init

 

Alex Dem

Hi,
I'll try to check with your path.
fyi: I have checked my example (with my path) on Z3 with : 

<script>
window.onload = function() {
    alert("onload");
};
</script>

It is ok too. 
Alexey.

Alex Dem

Strange if I located html file inside app folder (checked with your html on Z3) - alert are shown too.
I have used methods to compose path:
app_get_shared_resource_path()
app_get_resource_path()
Is your text "popup test" visible on window?
Alexey.

cs k

Yes I can see the "popup test" but the alert is not shown...

Also, I have checked with your html example but the result is same.

Furthremore I've checked same project on the Z1, the result is same too..

I think I might have used wrong code for the testing.

Would you share your testing project in here?

I would be grateful if you would help me to find out what is the problem with your testing code.

Thank you very much. :)

 

 

Alex Dem

Hi,
my code snippet  :

typedef struct _Browser_Window {
    Evas_Object *elm_window;
    Evas_Object *ewk_view;
} Browser_Window;

static void browser_create(Browser_Window *window ) {

    window->elm_window = elm_win_add(NULL, "minibrowser-window", ELM_WIN_BASIC);

    Evas *evas = evas_object_evas_get(window->elm_window);
    window->ewk_view = ewk_view_add(evas);

    elm_win_resize_object_add(window->elm_window, window->ewk_view);
    evas_object_show(window->ewk_view);
    evas_object_show(window->elm_window);

    view_focus_set(window, EINA_TRUE);
    char path[1024] = {0,};
    snprintf(path, 1024 - 1, "file://%sindex.html", app_get_resource_path());

    ewk_view_url_set(window->ewk_view,path);
}

static bool
app_create(void *data)
{
    Browser_Window *ad = data;
    browser_create(ad);
}

int
main(int argc, char *argv[])
{
    Browser_Window ad = {0,};
...
}

Alexey.

Alex Dem

view_focus_set should be commented  too (there some other logic)
Alexey.

cs k

I appreciate your help and the source code sharing.

I found the reason why the alert window is not displaying.

I forgot to call 'elm_win_resize_object_add()' for the webview.

So the alert window is showing well after adding it.

 

Thank you very much :)

Alex Dem

Hi ,
ok. Here are some explanations why it is needed:
https://developer.tizen.org/dev-guide/2.3.1/org.tizen.tutorials/html/native/web/web_tutorials_n.htm#layout
Alexey.