I have seen this link.
Browser detection in JavaScript?
My problem is slightly different .This link is for normal web pages. I want to detect browser from an iframe and want to display different content on the basis of browser.
let me explain in detail
We have built an application with asp.net and vb.net. Our client can integrate this application into their website as an iframe.
There are 10-12 pages in this iframe. code for one of the iframe page is like
<%@ Page Title="" Language="VB" MasterPageFile="~/cn/MasterPage.master" AutoEventWireup="false" CodeFile="login.aspx.vb" Inherits="pn_login" %>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" runat="Server">
<h2>Register or log in to apply</h2>
<div class="login-wrapper" id="safari">
XXXXXXXXXXX
</div>
<div class="login-wrapper" id="other">
YYYYYYYY
</div>
<asp:Content ID="Content3" runat="server" ContentPlaceHolderID="ScriptContent">
<script type="text/javascript">
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
</script>
The iframe and its pages works fine with all browser except from safari.So I only needed to detect if the browser is safari. The script code determines if the browser is safari. If the value of variable isSafari is true then the user uses safari otherwise the value is false.
So far so good. now we want to display different content depending on the variable. i.e.
if isSafari==True then
<div class="login-wrapper" id="safari"> xxxxx </div>
else
<div class="login-wrapper" id="other"> yyyy </div>
How can i do that?
For more information
Our web application is using master page and also database dependent. In master page we are already using a javascript function under body onload.
The code for iframes master page is .
<body onload="iframeResizePipe()">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div class="careers b-<%: CInt(Request("b"))%>">
<asp:ContentPlaceHolder ID="mainContent" runat="server" />
</div>
</form><br />
</body>
Please note
i dont want to just check the browser and tell user which browser they are are using. users know which browser they are using. i want to to detect the browser in the back end . if the user is using safari then i want to show him a different content. and if they are not using safari the content will be different
and i have also seen this link https://www.whatismybrowser.com/developers/tools/iframe. its not what i want
appreciate your suggestion.
Thanks