How to display external website as part of the app - reactjs

Referring to the image below, I need to display an external website on the right side of the screen when the link 'All chats' is clicked.
,
I tried to use window.location to achieve it but this is redirecting my site to the new site.
<RouteAuthenticated path={match.path} component={() => { window.location = 'https://www.google.com/'; return null; }} />
How can I get this done?

You can use iframes in the same way you can in standard HTML. Note that most website block being displayed in an iframe in other websites due to XSS vulnerabilities.
<iframe id="iFrameExample"
title="iFrame Example"
src="https://example.com">
</iframe>
One way around this is to use the sandbox attribute for iframes. See here for the different sandbox properties but they often will break functionality of the site. Other issues you may run into are iframe breakers which are basically unavoidable unless you have access to the code of the 3rd party website.

Yes, via iFrames it is possible to load webpages inside of other web pages.Window.location will not help you to do this. You have to use iFrames.

Related

is there a way to share react page on Facebook and pass an image?

am trying to make my react page shareable on Facebook and Twitter.
I tried everything I could, I have been googling all day, but I cant find the answer.
<FacebookShareButton url={window.location.href} title={exactNews.text ?exactNews.title : ""}>
<FaFacebookF/>
</FacebookShareButton>
any tips?
There is no way to pass an image to the share options anymore, the only way to add an image to a shared URL is by using the og:image tag in the source. Be aware that Facebook ignores JavaScript, so the og:image tag must be in the original source and not dynamically added via JavaScript. Facebook then automatically uses the image specified in the og:image tag.
More information: https://ogp.me/

How to include a full HTML file with specific styles inside a div

I'm making a script to preview email templates so I'm getting a full HTML page (with ) and I'm willing to make a popup with this page.
I'm getting the result from an API that gave me the full code inside a variable.
How to display this page inside my app without surcharging the styles ?
Thank you
Ps: I can't use an iframe since I can't get the preview from a simple get query (without header)
You can try one of these options (all of them have drawbacks)
ng-bind-html (AngualrJS directive) - doesn't provide styles encapsulation
iFrame - provides styles encapsulation, browser compatibility is not a problem. Still, you may need to set up or adjust your CSP policies if you are worried about security or have it already in place.
Shadow DOM - provides styles encapsulation, but you need to make sure it fits your supported browsers, and it's quite tricky to implement for AngularJS
UPD: based on your recent update, I guess you can proceed with ng-bind-html directive (HTML content will be sanitized, but you will have to cope with styles intersection and head & body tags warnings). If it doesn't work - try iFrame based on the approach referenced above (you don't need to make any external queries/requests for that).
iframe is the tag which you can use for call other html pages into your web page
<iframe src="http://www.page.com" name="targetframe" allowTransparency="true" scrolling="no" frameborder="0" >
</iframe>

Angular.js: Is there any disadvantage of hash in url with respect to SEO?

I am making a website using AngularJS, I am curious to know that is there any disadvantage of hash in url with respect to seo ?
e.g. http://www.website.com/#about-us
I'll appreciate any contribution.
Thanks
If we go back to the basics, HASH # means a DIV ID in your HTML, and to talk in more details Google ignores anything after the HASH.
Example, this page www.mydomain.com is similar to www.mydomain.com/#about-us
This is an advanced technique some marketers are using it to track their campaign without using parameters like UTMs to avoid content duplication.
To make sure your page is loading without any errors, try to disable the JS from your browsers using "Web Developer Tool" and then load your page, i think you will get a white page without content and this is the way Google and most of the search engines see your pages.
Also there is another way to test it by going to Search Console "Webmaster tool" and use fetch as Google, here you will see exactly how Google view your page.

Weird Content of Facebook share/like button preview from angular app

I have an issue with share/like button from Angular app. I finally made it working correctly with links but share/like preview if completely wrong. I tried XFBML.parse(), switching to html 5 mode, etc.
There are two complete enigmas:
1. I got "Given URL is not allowed by the Application configuration..." despite adding all possible variants to fb app setting.
When share preview appear - it has "Angular", but I never added it anywhere.
Here is the link
Would be grateful for any ideas...
Thx
The Facebook Scraper only looks at the HTML code your server delivers, it does not execute any JavaScript.
So if you want to share different articles, you need an individual URL for each article, that delivers the relevant meta data when requested from the server.
You can find some more explanation and hints on how to implement this in this article, http://www.michaelbromley.co.uk/blog/171/enable-rich-social-sharing-in-your-angularjs-app

A Link Inside an iFrame That Pops Up "Photo Theater"

I have a tab with an iframe external web page that loads... I would love a hyperlink inside that web page to link one of my photo albums in "theater" mode so you don't leave the page. However, any link I program inside that web page just brings in that photo album inside (not popped up and not in theater mode no matter if I have the &theater in the url).
Can I get some help on how to do this? Thanks!
this is a limitation of iframes in general. Less of a limitation and more of a security issue. As you said.. the iframe loads and external page - a page that could essentially come from anywhere. To protect the integrity of the site displaying this external page, the iframe can not access the page that contains it.
You might want to try opening a new window using javascript :
window.open ("{path_to_image}","title","menubar=1,resizable=1,width=350,height=250");
as you can see there are several options that you can set to customize the popup window.
Here is another link with some info about iframes

Resources