Forum Moderators: mack
<table><tr><td>data</td></tr></table>
You could modify this output like this:
table { width: 95%; }
td { background-color: #f5f5f5; }
However, if it loads into an iFrame or frame, no, you can't do much with that.
If you're slick with server side programming (asp, php, perl, etc.), the way to do this is have your page go get the data and use replacement methods to tweak it to your desire prior to output. This would be pretty easy to do.
Maybe didn't explain too well - the owner of the database provides links which I put on my site, and which fire off asp queries held on their server to their database and return the data as new html pages (obviously I can control whether or not these are in a new window/tab in coding the link)
Problem is I can apply all the css I want to my site, but when 'their' page is returned it uses 'their' css i.e if my site is orange text on a grey background and theirs is blue text on a white background (only an example)then aesthetically it looks awful. (obvious eaasy way out is to use same colors and fonts!) My question is, is there any way of applying my css to the their html output? (I have no access to their server, or to the database other than via these links)
The only way I would know to do this is to write a script (in any language) that queries the resource and you operate on it to extract the output.
<iframe src="myscript.asp"> (or Perl, or PHP)
myscript.asp captures the external resource, then stores only everything between <body> and </body>, then outputs it's own "page":
<html><head>
.. external link to your css
</head>
content captured above
Alter your CSS to add selectors for whatever elements or id's are in this document.
If they have the CSS inline, it's a little more complex, but can still be done. You would substitute every style attribute for an empty string, or your own classes. Depending on what is easiest for you, you can do any of the following substitutions:
style="font-weight:700" => '' (empty string, just take 'em out)
style="font-weight:700" => id="my-element-id"
style="font-weight:700" => class="some-class-for-this-element"
style="font-weight:700" => style="my-styling" (least flexible of all, mentioned so you don't do it. :-) )
Contents of myscript.cgi ...
1. Uses curl, wget, or similar page fetching mechanism to get the external .asp page.
$external_content = `curl http://example.com/some_page.asp`;
So now you have the entire page stored in the variable $external_content.
2. Operates on the captured content to filter out what you want. You perform the required operations on $external_content to strip everything but what you want out of it (examples above.) I'd post some code but I'd have to look up one of my projects or test it so it would be correct. :-)
3. Stores the captured and filtered chunk in a template. Now you've got the content, unstyled, in $external_content. Get your page template, which will have a "marker" in it for where this content goes. For example, if our "marker" is <!CONTENT>,
<html>
<head>
YOUR CSS
</head>
<body>
<!CONTENT>
</body>
</html>
Your script would do this
open (FILE,">template.txt");
# read in each line of your template
while ($line = <FILE>) {
if ($line =~ /\<\!CONTENT\>/) {
## Found the marker. Sub out the content
$line =~ s/\<\!CONTENT\>/$external_content/;
}
## Create a new variable, $final, that contains
## your template with the content
$final .= $line;
}
## Done, close the file.
close (FILE);
So you have the entire page with your template ready.
print "content-type:text/html\n\n";
print $final;
So when you click the link to myscript.cgi, "$final" is what comes out.