0

Good morning, I was reviewing other topics on the site but I could not find a way to solve my problem, at the end I will include some of the other topics on Stack that I was reviewing.

I am trying to create an html file that can read url parameter to invoke that url in an iframe in such HTML, e.g.: example.com/index.html?url=https://stackoverflow.com and this way I could load it from my site using an extractor I have.

This problem arises because I have several locations for files and I need to simplify the access to them but at the same time to have all of them in a list. When I tried to use some themes in Stack to find my solution it only caused a massive load of iframes opening and loading that never finished until it reached the limit of ram available on the server and in other cases it didn't read the url set in the parameter

Just in case, I clarify what I am looking for:

I have my site examplea.com and I want to display files through b.example.com?url=sitebackupA and so on, I just need to achieve a url parameter with javascript, thank you very much!


These are the other issues where I was checking and only the TypeForm was something close to what I need

Pass Incoming URL Parameters to iframe src with Javascript Using Javascript for iFrame src URL Changing iframe src with Javascript

picsoung
  • 6,314
  • 1
  • 18
  • 35
Scalix
  • 3
  • 2
  • You can't show a webpage in iframe if you are not from same origin or the owner has accepted it eg:- you can't embed the youtube site but, you can embed an yt video.Because it is allowed - I think – Musafiroon Aug 26 '21 at 02:14
  • I am aware of that, what I want displayed in the iframe has no CORS problem as I can easily invoke it with the PlayerJS script and a site from another guy. The problem I'm having is that I can't generate a proper code to grab the URL parameter and pass it to the iframe @Musafiroon, thanks for reply! – Scalix Aug 26 '21 at 03:07
  • answered it. please check – Musafiroon Aug 26 '21 at 04:19
  • @Musafiroon, it work perfect! – Scalix Aug 26 '21 at 13:17

1 Answers1

0

var url = new URL(location).searchParams.get('url');
document.querySelector("iframe").src=url;
<iframe></iframe>
Musafiroon
  • 623
  • 6
  • 20
  • Thank you very much, it works correctly, it seems that I had made a mess about parent and child because of the domain but it works perfectly, thank you very much! – Scalix Aug 26 '21 at 13:15