How to send the message from DialogFlow WebDemo from page javascript - iframe

I have a DialogFlow web demo page with trivial frame code
<iframe
name = "dialogflow_frame"
id = "dialogflow_frame"
allow="microphone;"
width="350"
height="230"
src="https://console.dialogflow.com/api-client/demo/embedded/_x_x_x_">
</iframe>
This show the embedded DialogFlow chat on my page.
I want to send some message string from my page to chat with some page JavaScript command (for example - some content from this page).
How to send the message from page code? I've try to search the iframe form, but it's doesn't available from code.
<iframe
name = "dialogflow_frame"
id = "dialogflow_frame"
allow="microphone;"
width="350"
height="230"
src="https://console.dialogflow.com/api-client/demo/embedded/_x_x_x_"
onload="console.log('onload'); var f=document.getElementById('query'); console.log(f);"
>
In this code f (search for query field) return null.

Due to the same-origin policy, you can't access the DOM of the iframe from the javascript on your page, so this is not possible.

Related

Load another page when iframe loads

Hey all thx for your time!!.
I want to add a login page at my website. So, i am using iframe and centered it to show the username,password and connect button. But, i want my page to load the iframe page when user click the connect button inside the iframe.
First, i want them to add the username and password info. And click load, then the page reloads but keeps their info (i hope).
Here is the code
<iframe id="iframe" scrolling="no"
src="http://sms.altasoft.gr/panel/index.asp?lang=el&disp_function=user_login&id=5E8A0F4B-063B-4A7A-81FE-99579AF44BAA">
<p>Your browser does not support iframes.</p>
</iframe>
If the page loaded into the iframe uses some cookies to keep the log in information, this should work:
<script type="text/javascript">
window.onload = function(){
var iFrame = document.getElementById("iframe");
iFrame.onload = function(){
window.location = iFrame.src;
};
}
</script>
If I understand correctly, you're using an iframe and want to have the main page reload when the form inside the iframe has been submitted. Is that correct? If so, add ' target="_top"' to the form inside the iframe, and it should reload the whole thing.

How to pass credentials when accessing SSRS report through URL

I am trying to access a SSRS report using URL like below
http://MyServerIP/ReportServer?/FolderName/ReportName&Param1=ParamValue&rs:Command=Render&rs:Format=HTML4.0&rc:Toolbar=false
When I try to access above Url, I am asked for my network credentials, giving which I get all pages of SSRS report rendered in browser window.
Now I want to display these contents in a popup window inside my webApp. For this I tried to make a jquery request and get contents, but doing this I get 401 unauthorized error. So I wanna know if there is a way to send credentials in jquery ajax get request.
As a turnaround I tried using below C# code to retrieve data, but it didn't helped either and gave same 401 error
WebClient client = new WebClient();
client.Credentials = new NetworkCredential("username", "password", "domain");
divContents.InnerText = client.DownloadString(my report path);
I am using SSRS 2008 R2 and my requirement is to show all pages of report in popup window. So all pointers in this direction are welcome.
Adding a point at last, my web app and report may or may not reside on same domain.
Thanks,
Ravi
What I would try:
Create a new page. On the C# side, use the ReportExecution2005 web service to render your report to HTML. Then pump the result out to the window.
In your pop-up, either call the new C# page via Ajax (to get the HTML) and inject the output into your jQuery window, or pop up the page itself as a separate browser window.
I can provide some sample code if you need it.
ETA: I found a possibly valuable piece of information:
This is from the HTML Device Settings page (emphasis mine):
Toolbar
Indicates whether to show or hide the toolbar. The default of this
parameter is true. If the value of this parameter is false, all
remaining options (except the document map) are ignored. If you omit
this parameter, the toolbar is automatically displayed for rendering
formats that support it.
The Report Viewer toolbar is rendered when you use URL access to
render a report. The toolbar is not rendered through the SOAP API.
However, the Toolbar device information setting affects the way that
the report is displayed when using the SOAP Render method. If the
value of this parameter is true when using SOAP to render to HTML,
only the first section of the report is rendered. If the value is
false, the entire HTML report is rendered as a single HTML page.
You pass the credentials like this in the query string:
dsu:DataSourceName=userName&dsp:DataSourceName=password
Replace the elements in bold with the values from your report, for example:
http://MyServerIP/ReportServer?/FolderName/ReportName&Param1=ParamValue&rs:Command=Render&rs:Format=HTML4.0&rc:Toolbar=false&dsu:Data=reportreader&dsp:Data=password1
You can use the Report Viewer control if you want to allow public access to secure reports without asking for credentials.
Create a new .aspx page and use the ReportViewer control like so:
<rsweb:ReportViewer ID="MainReportViewer" runat="server" BackColor="White"
Font-Names="Verdana" Font-Size="8pt" InteractiveDeviceInfos=" (Collection)"
ProcessingMode="Remote" ShowBackButton="False" ShowFindControls="False"
ShowPageNavigationControls="False" SizeToReportContent="True"
ToolBarItemBorderColor="White" ToolBarItemHoverBackColor="White"
WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Width="100%">
<ServerReport ReportServerUrl="" />
</rsweb:ReportViewer>
The code below can be used in the codebehind of your .aspx page to configure the report server, username and password, [etc..] in your Report Viewer
protected void Page_Init(Object sender, EventArgs e)
{
string UserName = ConfigurationManager.AppSettings["SsrsUserName"];
string Password = ConfigurationManager.AppSettings["SsrsPassword"];
string Domain = ConfigurationManager.AppSettings["SsrsDomain"];
string ReportServerRoot = ConfigurationManager.AppSettings["SsrsServerRoot"];
string ReportServerPath = ConfigurationManager.AppSettings["SsrsReportServerPath"];
MainReportViewer.ProcessingMode = ProcessingMode.Remote;
IReportServerCredentials irsc = new CustomReportCredentials(UserName, Password, Domain);
MainReportViewer.ServerReport.ReportServerCredentials = irsc;
MainReportViewer.ServerReport.ReportServerUrl = new Uri(ReportServerRoot);
MainReportViewer.ServerReport.ReportPath = ReportServerPath + "YourReportFileName";
}

Check if my iframe is in a Facebook document?

I have created a Facebook app to house my site within an iframe.
At every request I want to check that the site is inside the Facebook app, otherwise I want to redirect the user to the Facebook app.
I can check that I am within an iframe with javascript:
if (top != self)
But I don't know if I'm actually inside the Facebook app.
The cross-domain security hinders me from accessing the parent document's info. For example, "top.location.href" cannot be accessed.
Can someone help me out? :-)
Facebook attaches a value to window.name so you can use JavaScript to check.
if(window.name.indexOf('iframe_canvas_fb') != -1){
// in Facebook
} else {
// not in Facebook
}
You can check FB.Canvas namespace methods from facebook's javascript library. It will work on Facebook canvas.
https://developers.facebook.com/docs/reference/javascript/FB.Canvas.getPageInfo/
check what info do you get while in the facebook's iframe, outside iframe or in another iframe.
hope this helps
Well if the user is outside of Facebook this bit of script before the body html tag should redirect them back to your page on Facebook:
<script language="JavaScript" type="text/javascript">
<!--
if (self == top) {
window.location = "http://apps.facebook.com/YOUR_APP_PAGE";
}
-->
</script>
remember to change the 'YOUR_APP_PAGE' bit to something like:
'my-application?app_data=page-location'
you can send the request ?app_data to your Facebook page using php and append the page that your website was redirected from so that the app_data can tell your app to load this page but within Facebook.
So it is worth looking up Facebook app_data
If you want to change the style of your page depending if it is displayed on Facebook or not then use this:
<script language="JavaScript" type="text/javascript">
<!--
if (window.self = "http://apps.facebook.com/") {
var element = document.getElementById('html');
element.className = "facebook";
}
-->
</script>
and modify your html tag with the id=html like so:
<html id="html" xmlns:fb="http://www.facebook.com/2008/fbml">
this will allow you to use a class name .facebook remap any style for your page that you like.
If you need to set some initial php settings like the redirect page, then you can use this code in php to detect if you are within Facebook, however this code can not detect if the user is on Facebook or not after they have logged in:
if(!empty($_POST['signed_request'])){
//do something with php here...
}
Note:
It is unlikely the Facebook user on your app page has JavaScript turned off which is why we can use the above php code to set redirects etc...
php should not really rely on $_SESSION or cookies for this in case the user decides to visit your page having logged in to your Facebook application, it would take a page refresh for php to determine that they are no longer in Facebook from the session or cookie.
After thought:
All this information should be on the Facebook SDK's as managing redirects and application detection is a nightmare with Facebook's horrific documentation.
Hope this helps you out :)

Url of the loaded html in an Iframe

We have a customer portal site hosted externally.
I need to create a page in our company site where in employees will use the page to login to the portal. The login page they offer is generic
To implement this, I am planning to create a page and then iframe (width: 200px ; height:100 px) the login page of the customer portal. This way I can have the company branding on the login page..
But my problem is, when user logs in via the iframe, the resulting home page opens within the iframe window.
My question: is there a way to find the url of the page that is loaded in the iframe so that based on the url, I can change the dimensions of the iframe?
The src attribute of iframe always shows the login page url.
My Iframe code:
<iframe onload="loadMyFrame();" src ="https://login.tomyportal.com" width ="370" height="200" id="sWindow" frameborder="0"></iframe>
<script type="text/javascript" language="javascript">
function loadTest() {
var ifr = document.getElementById("sfWindow");
alert(ifr.src); //the value returned is always login page.
}
</script>
how about
alert(ifr.location.href)
?

Retrieving anchor link in URL for ASP.NET

I have a URL like so:
http://localhost/place/663828/bangkok-paradise-restaurant-toronto#r306040
I am trying to see if there's the existence of the anchor tag along with getting its value to do some code logic in the code behind.
I have been trying to use the Page.Request, but none of the properties show the anchor link portion of the URL.
For example:
Response.Write(this.Page.Request.RawUrl.ToString());
I pretty much tried the combinations/properties on this page: http://www.west-wind.com/weblog/posts/269.aspx
Just to finalize this topic:
I copied Stack Overflow's approach with a permalink... :D
It's not possible to retrieve the #anchor from the server side in ASP.NET.
This is a client-side flag to tell the browser to move to a specific place within the page.
You can use some JavaScript code in the body onLoad event to check for an anchor and send it back to the server using Ajax.
var anchorValue;
var url = document.location;
var strippedUrl = url.toString().split("#");
if(strippedUrl.Length > 1)
anchorvalue = strippedUrl[1];
Ref: Retrieving the anchor value from a URL
Being more explicit, the anchor tag is never sent as part of the HTTP request by any browser. It is only interpreted locally within the browser. Neither ASP.NET nor any other web server technology, Microsoft or otherwise will see the anchor on that request.
RFC 1808
Section 2.4.1 -
"Note that the fragment identifier is not considered part of the URL."
As others have suggested, the nearest you could get would be using client-side to read the browser window location.
A fragment can be parsed from a URL in C# in the following way:
var uri = new Uri("http://localhost?id=2#token=23");
var fragment = uri.Fragment; // Will return #token=23
There is a problem however in that the browser won't send fragments to the server. If you receive requests from a service that includes this information in the request, it will be available from the server side too.

Resources