/    Sign up×
Community /Pin to ProfileBookmark

iFrame Target Link Not Working. Why ?

Folks,

Here is an iFrame. You get a link and if you click it then the link’s url should open in an iFrame.
Can you tell me why clicking the link does not open it’s url in the iFrame ? I see a blank page in the iFrame! What is wrong ?

[code]
Target Link
<iframe height=”300px” width=”100%” src=”http://www.yahoo.com” name=”iframe_a”></iframe>

<p><a href=”https://www.yahoo.com” target=”iframe_a”>Yahoo.com</a></p>

<p>When the target of a link matches the name of an iFrame, the link will open in the iframe.</p>
<br>
[/code]

to post a comment
Full-stack Developer

12 Comments(s)

Copy linkTweet thisAlerts:
@developer_webauthorMar 04.2020 — Folks,

Another question.

Is there any way to log what url has loaded on an iFrame ?

You see, if you come to my website homepage, for example, I want to show you a third party website in an iFrame. Like say yahoo.com. (Don't ask me why).

Now naturally, I'd know which url you are browsing on that iFrame since I'll be fixing the url the iFrame should load to. In this example, yahoo.com.

Now, if you click any link found on that iFrame loaded page (yahoo.com homepage) or type a new url (eg. ebay.com) for the iFrame to fetch that new page, then I want that new page's url (in this example 'ebay.com') logged onto my mysql database so I can record what pages on third party websites you are viewing on the iFrame.

So how to do this ?

I know how to log variable values onto mysql database. Don't worry about that.

I'm having trouble how to add the iFrame fetched page's url onto the $src variable.

Once I can figure how to do that, then all I'll have to do is just log the $src value onto my mysql database using the php-mysql INSERT command.

Now show me how to get the $src variable to watch what new urls are loading on the iFrame.

This is as far as I went ...

<i>
</i>&lt;?php
$src = http://www.yahoo.com; //The first page the iFrame loads to when you visit my homepage.
?&gt;
&lt;iframe height="300px" width="100%" src="&lt;?php echo 'http://www.yahoo.com' ";?&gt; name="iframe_a"&gt;&lt;/iframe&gt;


No. Do not tell me to write a web proxy. They are server bandwidth hogs.

iframes are better as pages loaded on iFrames are not served by my the website's webserver (serverside) but by the visitor's web browser (clientside).

In other words, is there away to do clientside logging with php ? If not, then with javascript ?

maybe javascript grab the $src value and forward it to php for php to dump the $src value to the mysql database ? If this is possible, then someone care to show a javascript sample. I don't know javascript atall.

By the way (btw), do not forget to address my original post.

Cheers!
Copy linkTweet thisAlerts:
@NogDogMar 09.2020 — [[19,23],[2,11]]
Copy linkTweet thisAlerts:
@developer_webauthorMar 11.2020 — Folks,

It's been 10 days since I opened this thread. I got no response.
Copy linkTweet thisAlerts:
@cootheadMar 11.2020 — Hi there developer_web,

many sites do not want their pages stuck in 3rd party iframes.

This blocking can done in a variety of ways including _JavaScript_ and _PHP_

As _JavaScript_ can be disabled it is not a viable solution.

**PHP**

[url=https://coderwall.com/p/kdv1hw/prevent-rendering-your-page-inside-an-iframe-using-x-frame-options]Prevent rendering your page inside an iframe using X-Frame-Options[/url]

There is no advantage for Yahoo having it's pages stuffed into your Iframe,

so it blocks it permanently.

What method it actually uses though, I cannot say.

_coothead_
Copy linkTweet thisAlerts:
@NachfolgerMar 11.2020 — @developer_web#1616014 As mentioned by @coothead#1616028, it's blocked by a header from Yahoo. The solution would be to get the contents of the said page and echo them out via PHP (or any backend language).

If you have to use a iframe, you can still iframe your own website.

Eg. index.html
``<i>
</i>&lt;html&gt;
&lt;body&gt;
&lt;iframe src='/iframe_source.php?url=1'&gt;&lt;/iframe&gt;
&lt;/body&gt;
&lt;/html&gt;<i>
</i>
`</CODE>
iframe_source.php<br/>
<C>
`
&lt;?php<br/>
if ($_GET['url'] == 1) {<br/>
die(file_get_contents("https://yahoo.com"));<br/>
}<br/>
?&gt;
``

This is a hyper abstract demonstration, and you should implement more validation and security, but you get the point.
Copy linkTweet thisAlerts:
@developer_webauthorMar 16.2020 — @Nachfolger#1616040

Mmm. Not sure what to do now.

You see, if I "get the contents of the said page and echo them out via PHP" then I'm gonna have to do that with cURL. Right ? And grabbing html of said pages and echoing them is like building my own web proxy. Problem is, web proxies are bandwidth hogs since the page fetching is done on serverside.

That's why I wanted the said pages' htmls to be fetched on the clientside and to do that the best I could come-up with is fetch pages with iframes.

I'll tell you guys what I really want to do. I want to log what each member of mine browses.

Let's say you 3, who replied to this thread so far, are my members. Now, I'd give you a web proxy and you 3 would use it to surf the net and I would be able to log what you 3 members are browsing and check your logged browsing histories to learn your surfing habits (for advertising purposes).

Now, like I said before, running a web proxy heavily eats-up bandwidths on the serverside because the server fetches the pages.

Now how to restrain too much bandwidth consumption so my server's monthly bandwidth doesn't get eatup too quick before the month is over ?

I thought if I show each member an iframe on their account homepages then they can browse their chosen urls on the iframe and I can get the iframe to log what urls they are browsing (what urls are loading on the iframe). Logon to my mysql db.

So, how to log what url is being fetched by the iframe ?

Right now, I can put any url on the "src=" part of the iframe html and the iframe would fetch the said page and I can write php code to dump the url onto my mysql db.

But when you manually type another url on the iframe and it loads your chosen page, then I ain't to know what url you typed and what page you are visiting unless I can get the php to grab the newly typed url and dump it to my mysql db.

And so, how to write php code or javascript code that will monitor what url is being fetched by the iframe when you manually type a url for the iframe to fetch it's page ?
Copy linkTweet thisAlerts:
@developer_webauthorMar 22.2020 — @Nachfolger

Can you reply to my previous post on this thread ?
Copy linkTweet thisAlerts:
@valentind66Apr 03.2020 — @CCKitty#1616075

You're absolutely right, but RSS feeds are times
×

Success!

Help @developer_web spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...