The Most Active and Friendliest
Affiliate Marketing Community Online!

“Adavice”/  “1Win

Using a Mobile Detection Script

JailHouse

Member
I have download a mobile detection script which contains PHP code.

I put that in a php file and upload it to my server. Then I visited the page and it shows nothing.

How do I display the name of the phone on my lander using the script?

Should I look for a piece of code or variable within the code that I can copy and paste within my html where I want it to display the phone name?

JH
 
I have download a mobile detection script which contains PHP code.

I put that in a php file and upload it to my server. Then I visited the page and it shows nothing.

How do I display the name of the phone on my lander using the script?

Should I look for a piece of code or variable within the code that I can copy and paste within my html where I want it to display the phone name?

JH

Cant say anything unless you show us the code.
 

Attachments

  • detect.php.zip
    22.2 KB · Views: 50
Ok I thought you are going to use php, sorry for confusion.
From you post it seems you want html only (Javascript based) solution.
For that you can use the below

<script type='text/javascript' src="//wurfl.io/wurfl.js"></script>

This will return a JSON object that looks like:

{
"complete_device_name":"Google Nexus 7",
"is_mobile":true,
"form_factor":"Tablet"
}
now get the modelname like

modelName = WURFL.complete_device_name
 
I can use php.

Thanks for this. I got it now.

Next problem is that I cant use <?php echo $detecttype ?> anywhere on my page because building my page in Adobe Muse, it turns the text into an image.

Do you know how I can get out of that?

Can I use some other tool to build my lander?

I would like to use the Bootstrap thing that was suggested but just need something barebones and simple.

JH
 
Just select a web safe font in MUSE and that should prevent the text turning in to images.

Excellent, thanks for that. That's the solution I needed.

Now, I'm using the mobile_detect.php script and the output is something like this:

Your phone/computer is "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:32.0) Gecko/20100101 Firefox/32.0".

I just want it to say "Your phone is a Samsung Galaxy Note II"

Does anyone know what to edit in mobile_detect.php to have it say just that much?

JH
 
Ok I thought you are going to use php, sorry for confusion.
From you post it seems you want html only (Javascript based) solution.
For that you can use the below

<script type='text/javascript' src="//wurfl.io/wurfl.js"></script>

This will return a JSON object that looks like:

{
"complete_device_name":"Google Nexus 7",
"is_mobile":true,
"form_factor":"Tablet"
}
now get the modelname like

modelName = WURFL.complete_device_name


Can you explain how I would echo the output?

I pasted the script tag in the <head> part of my site and then after that, I'm lost.

Can you help?

JH
 
Take this,

1. Download the wurfl.js into a folder . (consider a folder 'js' inside the folder where your main index.html resides).
2. Write the code in your index.html like below

<html xmlns="XHTML namespace">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type='text/javascript' src="js/wurfl.js">
</script>
<title>Untitled Document</title>
</head>
<body>
<script type="text/javascript">
console.log(WURFL);
document.write(WURFL.form_factor);
</script>
</body>
</html>

----NOTE : console.log is just optional. You will get the device type/model in WURFL.form_factor variable.

Assuming you know javascript.
 
Thanks for that. I understand all of this.

But I dont know javascript. How can I echo the device model in my web text. Do you have the code for that?

Really appreciate the help,

JH
 
document.write(WURFL.form_factor);

Did you even notice the line above in my code??

If you want to learn, then first step in learning is keen observation to details.
 
Great, that seems to work, but the problem now is that it always outputs "Desktop" even when I access my page from a iPhone.

It should output iPhone.

Could it be the lack of info inside the wurfl.js file?

JH
 
banners
Back