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

custom user-agent on pop-up? #108

Open
zerosix opened this issue Apr 28, 2014 · 6 comments
Open

custom user-agent on pop-up? #108

zerosix opened this issue Apr 28, 2014 · 6 comments

Comments

@zerosix
Copy link

zerosix commented Apr 28, 2014

I am using the custom user agent macgap.setCustomUserAgent('MyUA'); and it works fine on the main window. However, if I create a pop-up window in javascript, its user agent is defaulted. I would like the pop-up to also be this custom user agent string.

I am calling the pop-up with:

onclick="Popup=window.open('url.html','Popup','toolbar=yes, location=no,status=no,menubar=no,scrollbars=yes,resizable=yes, width=1024,height=768'); return false;"

@jeff-h
Copy link
Member

jeff-h commented Apr 28, 2014

Good catch. Would there ever be a use-case for setting a specific UA on a per-window basis? If you think not, I'll look into getting all new windows opening with the UA specified by macgap.setCustomUserAgent()

@zerosix
Copy link
Author

zerosix commented Apr 28, 2014

Not that I can think of off hand! Thanks for the quick response

@jeff-h
Copy link
Member

jeff-h commented Apr 28, 2014

It won't be trivial; since you can call macgap.setCustomUserAgent() at any stage, we'll have to go through every open window (of which there could potentially be many) and change the UA on the webview inside every one of them.

Another question for you — can you think of any use case for actually changing the UA dynamically? In other words, could we remove macgap.setCustomUserAgent() and instead require developers to set a UA value in a plist or XML file or something (if they don't want the default)? Really it feels like it belongs in Classes/Constants.h — take a peek at that and see what you think.

@zerosix
Copy link
Author

zerosix commented Apr 29, 2014

I think that a plist would be best, IMO that way it is a global setting. I've been racking my brain trying to think of a situation where I would need the UA to be anything other than what's defined, and every situation I can think of would be satisfied with a new compile with a different UA across the board.

@jeff-h
Copy link
Member

jeff-h commented Apr 29, 2014

Great, that sounds quick to implement :) I think I'll just stick it into Constants.h. Will try and get onto it in the next few days.

@zerosix
Copy link
Author

zerosix commented Apr 30, 2014

of course now that i've said that I can think of a few uses for different user agents on popups (load different css based on UA, for example)

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

2 participants