Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

executescript not working #8

Closed
skhurams opened this issue Apr 1, 2015 · 6 comments
Closed

executescript not working #8

skhurams opened this issue Apr 1, 2015 · 6 comments

Comments

@skhurams
Copy link

skhurams commented Apr 1, 2015

Hi i want to get current page title how do i get this. my ref.executescript is not working.
heres what i have done so far

 function innAppInit(_url) {
 app.Log('browser news link=' + _url);
  if (_url == null) {
    _url = 'http://apache.org';
  }
var ref = cordova.ThemeableBrowser.open(_url, '_blank', {       

    statusbar: {
        color: '#239EC9'
    },
    toolbar: {
        height: 44,
        color: '#239EC9'
    },
    title: {
        color: '#FFFFFF',
        showPageTitle: false,
        staticText: 'Add New Web Page'
    },
    backButton: {
        image: 'back',
        imagePressed: 'back_pressed',
        align: 'left',
        event: 'backPressed'
    },
    forwardButton: {
        image: 'forward',
        imagePressed: 'forward_pressed',
        align: 'left',
        event: 'forwardPressed'
    },
    closeButton: {
        image: 'close',
        imagePressed: 'close_pressed',
        align: 'right',
        event: 'closePressed'
    },
    customButtons: [{
        image: 'share',
        imagePressed: 'share_pressed',
        align: 'right',
        event: 'event_getThumb'
    }],     
    backButtonCanClose: false
 });
}

     ref.addEventListener('loadstop', function(event) {
         try {

             ref.executeScript({
                     code: 'return document.title'
                 },
                 function(values) {
                     alert(values);
                     $('#txtDisplayName').val(values);
                 });
         } catch (e) {

         }
     });
@initialxy
Copy link
Owner

In order to reduce magical behaviour, there is now a flag to indicate if current page title should be shown. See showPageTitle

  • staticText sets static text for title. This property overrides showPageTitle (see below).
  • showPageTitle when set to true, title of the current web page will be shown.

One thing to keep in mind is that staticText will override showPageTitle so you need to remove your staticText property. So it should look something like

title: {
    color: '#FFFFFF',
    showPageTitle: true
}

@initialxy
Copy link
Owner

O I see you are trying to retrieve document.title through executeScript. Can you please elaborate on how it's not working? What do you see from log? If you open Safari remote debugger and look at console, do you see any JavaScript errors?

@skhurams
Copy link
Author

skhurams commented Apr 1, 2015

no errors actually when i run js debugger the code is not executed at all.

@initialxy
Copy link
Owner

The code you execute should be

document.title

Not

return document.title

eg:

ref.executeScript({
    code: 'document.title'
}, function(values) {
    alert(values);
});

@skhurams
Copy link
Author

skhurams commented Apr 1, 2015

thanks it helped

@anilk533
Copy link

HoW TO ADD LAODER IN IONIC themeable browser????????? and how to change title text dynamically when load start and load stops?
currently iam adding laoder on on event start but it showing the loader in themebrowser. its showing when themebrowser closes.(i mean showing in prev page).

var ref = cordova.ThemeableBrowser.open(link, '_blank', {

                        statusbar: {
                            color: '#f24f4f'
                        },
                        toolbar: {
                            height: 40,
                            color: '#f24f4f'
                        },
                        title: {
                            color: '#FFFFFF',
                            showPageTitle: false,
                            staticText: 'Add New Web Page'
                        },
                        /*backButton: {
                            image: 'back',
                            imagePressed: 'back_pressed',
                            align: 'left',
                            event: 'backPressed'
                        },
                        forwardButton: {
                            image: 'forward',
                            imagePressed: 'forward_pressed',
                            align: 'left',
                            event: 'forwardPressed'
                        },*/
                        closeButton: {
                            image: 'close',
                            imagePressed: 'close_pressed',
                            align: 'right',
                            event: 'closePressed'
                        },
                        /*customButtons: [{
                            image: 'share',
                            imagePressed: 'share_pressed',
                            align: 'right',
                            event: 'event_getThumb'
                        }], */    
                        backButtonCanClose: false
                     });

        //}); 

        ref.addEventListener('loadstart', function(event) {
            $rootScope.LoaderShow();
        });
        ref.addEventListener('loadstop', function(event) {
            $ionicLoading.hide();
        });
        ref.addEventListener('event_getURL', function(event) {

        });
        ref.addEventListener('exit', function(event) {
            $ionicLoading.hide();
        });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants