user-agent

Dynamic CSS3 prefix user agent detection

我们两清 提交于 2019-12-06 11:59:38
问题 Is there a better way then using jQuery.browser, or equivalents, for determining css 3 prefixes (-moz, -webkit, etc), as it is disencouraged? Since the css is dynamic (the user can do anything with it on runtime), css hacks and style tag hacks can't be considered. 回答1: I don't see the issue with using the navigator.userAgent to determine if you need to cater for Webkit / Gecko CSS3 prefixes. Or better yet, just stick with CSS2 until CSS3 becomes a W3C Recommendation. The reason use of the

Add custom header in Selenium and Sauce Labs?

南笙酒味 提交于 2019-12-06 10:45:54
I use Selenium and Sauce Labs for testing. Is there a Selenium property to add a custom header or append a string to the user agent (like "using Sauce Labs")? I want to selectively not load some content for Selenium, because it is causing the units tests to be too finicky. I have some widgets on the page, and sometimes the page doesn't complete loading... so I want to selectively not display them for Selenium. I'm not familiar with Sauce Labs, but you can certainly do this on some Selenium setups, by changing the general.useragent.override , as follows (which may be adaptable): Using the

Change User-Agent Using PHP

爱⌒轻易说出口 提交于 2019-12-06 10:35:17
I have an app on my server which redirects to Facebook and thus displays the browser version of the Facebook Login page. However, since I'll be accessing this through a mobile device, I'll want it to display the mobile version of the Facebook login page. Is it possible to use the header() function or is there a way to change the user-agent on my host before it redirects to Facebook? So that Facebook will think the request is coming from a mobile device and thus render the mobile version. I have already tried to use JavaScript and tried spoofing the header command; unfortunately these didn't

How to block some of http user agent using php

笑着哭i 提交于 2019-12-06 08:42:51
问题 there have a way to block some of user agent via php script? Example on mod_security SecFilterSelective HTTP_USER_AGENT "Agent Name 1" SecFilterSelective HTTP_USER_AGENT "Agent Name 2" SecFilterSelective HTTP_USER_AGENT "Agent Name 3" Also we can block them using htaccess or robots.txt by example but I want in php. Any example code? 回答1: I like @Nerdling's answer, but in case it's helpful, if you have a very long list of user agents that need to be blocked: $badAgents = array('fooAgent',

DOMDocument::loadHTMLFile() modify user agent

怎甘沉沦 提交于 2019-12-06 06:11:40
Im using PHP to load a website in a DOM Tree. Is there a way to modify the user agent that is sent using DOMDocument::loadHTMLFile() ? function parseThis($url) { $html = new DOMDocument(); $html->loadHtmlFile( $url ); return $html } Change the user_agent value in php.ini , which should be sent in anything making use of the http stream wrapper like DOMDocument::loadHtmlFile(), file_get_contents() , etc. $fake_user_agent = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11"; ini_set('user_agent', $fake_user_agent); The same can also be

Dynamically change url or WordPress theme if UserAgent is iPhone

陌路散爱 提交于 2019-12-06 05:39:51
Is there any way to do this? My website is http://kennethreitz.com . Its driven by some moderate PHP on top Wordpress. My options are to detect if the user is using an iphone, and if they are either a) tell wordpress to load a different "theme" that i have written. b) if this isn't possible, have a different wordpress installation on a subdomain (i.kennethreitz.com) that operates out of the same database, that uses a different theme. I'd rather be able to do A for SEO reasons. Any ideas? http://www.nathanrice.net/blog/serve-ie6-visitors-the-default-wordpress-theme/ demonstrates how to use

Fail to enroll IOS device in WSO2 2.0.1

这一生的挚爱 提交于 2019-12-06 04:57:30
Trying to enroll IOS device (IPhone 6s, ios 9.3) in WSO2 but unfortunately failing. I am using registered csr file and Apple MDM certificate. Followed instructions mentioned in document. Failing at step 2 on IOS device after entering Domain, username and password. On UI, below is the error "An unexpected error occured. Please try again." In Logs I see below errors: [2016-05-06 11:54:22,746] ERROR {org.wso2.carbon.device.mgt.ios.util.OAuthUtils} - Error occurred while sending 'Post' request due to failure of server connection javax.net.ssl.SSLException: hostname in certificate didn't match: <10

Switching stylesheet with Javascript based on browser

若如初见. 提交于 2019-12-06 04:32:35
问题 I'm currently trying to edit a website for a client which uses Adobe Contribute so it uses a different stylesheet if the user is browsing from a mobile phone. The mobile phone stylesheet is much simpler and strips out background images and styles to reduce load time. I understand it would be better practice to have a completely seperate website for the mobile, but this is not practical for the client as he needs to be able to update his websites content using Contribute. This is working in

How can I spoof the user agent of a JavaScript GET request?

不羁岁月 提交于 2019-12-06 03:51:07
问题 How can I spoof the user agent of a JavaScript GET request? setRequestHeader with User-Agent isn't allowed: xmlHttpRequest.setRequestHeader("User-Agent", "..."); 回答1: You can't do this in a half-decent browser because of security issues surrounding it. You don't want XSS scripts to be changing request headers and running rampant on your site. However I believe there's a workaround in IE if you use VBScript: MyHttp.setRequestHeader "User-Agent", "MyCustomUser" The alternative is to have a web

Distinguish between iPad and mac on iPad with iPadOs

耗尽温柔 提交于 2019-12-06 02:49:25
问题 In iOS 13 apple changed the user-agent that iPad uses. Instead of (for example) Mozilla/5.0( iPad ; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10 it become (for example) Mozilla/5.0 ( Macintosh ; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 Safari/605.1.15 My question is how can we distinguish between iPad and mac now? 回答1: The condition I used to detect IpadOS: ua.toLowerCase()