I am calling some data from iframe.

<iframe id="pframe" width="'.$game['iframewidth'].'" height="'.($game['iframeheight'] + 20).'" src="'.$path.'"  frameborder="0" scrolling="no" align="middle"></iframe>';

i want to call my css for this frame ?

How to call css for iframe??

the source for an iframe is a html file (xhtml php cgi asp etc)
you just put the css, or a call to the .css file in the <head> of the source file, the same as any other html file

here is what your opening html tag and head tags should look like.

<html>
<head>
<title>YOUR TITLE HERE<title>
<link rel=stylesheet type=text/css href=YOURCSSFILE.css>
</head>

I am asking about ...
is it possible to change the css of iframe...??

suppose i am on www.abc.com and my file is test.php
iframe is defined in test.php
$path="www.xyz.com/ddd?id=123"

<iframe id="pframe" width="'.$game['iframewidth'].'" height="'.($game['iframeheight'] + 20).'" src="'.$path.'" frameborder="0" scrolling="no" align="middle"></iframe>';

that means in this iframe data of xyz.com ...
so is it possible to change css or design??

no if it is from another site. Basically an iframe is a way of implementing html in a window inside the original window. What the iframe is acting as is basically like a browser window, except its implemented with in a html document. You cannot change the style or css of another site if the iframe is directly linked to that site. Just like you cannot change the style of daniweb inside your browser window.

Well since this is a PHP forum, i'll give you a PHP solution. You could pass the css file for the iframe to use in the url like so:

<iframe id="pframe" width="'.$game['iframewidth'].'" height="'.($game['iframeheight'] + 20).'" src="'.$path.'?style='.$style.'" frameborder="0" scrolling="no" align="middle"></iframe>

where style is the css file. In the iframe page, get this value from the $_GET superglobal and (after some error checking/security checks!!!) print the reference to this external stylesheet.

commented: Thanks Bloke, hadnt seen this approach before, way more efficient than duplicating content between domains +1

Well since this is a PHP forum, i'll give you a PHP solution. You could pass the css file for the iframe to use in the url like so:

<iframe id="pframe" width="'.$game['iframewidth'].'" height="'.($game['iframeheight'] + 20).'" src="'.$path.'?style='.$style.'" frameborder="0" scrolling="no" align="middle"></iframe>

where style is the css file. In the iframe page, get this value from the $_GET superglobal and (after some error checking/security checks!!!) print the reference to this external stylesheet.

This type of code may open you to a security problem , because you can direct this to a aribritary maclious CSS file.

Most often , there can be many possibilities for an XSS with other source complixities.

To quote myself for emphasis:

(after some error checking/security checks!!!)

In the page inside the iframe, thoroughly check the css file requested. I would make sure it is one of a select number of specific filenames, rather than checking just the extension, etc.

To quote myself for emphasis:

In the page inside the iframe, thoroughly check the css file requested. I would make sure it is one of a select number of specific filenames, rather than checking just the extension, etc.

Thank you Death,
I have clips now from one site working in another, like they belong, despite there being vastly different css.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.