Welcome to WebmasterWorld Guest from

Forum Moderators: brotherhood of lan & mack

Styling ASP output without source

Is it possible?

9:26 am on Sep 23, 2008 (gmt 0)

5+ Year Member

The data for my website is supplied from a third party database. The queries are ASP pages hosted on their server to which I have no access, although I am authorised to use the data. To suit the style of my site the format of the data, colors fonts etc - needs to be different - is there any way of reformatting the html output without access to the ASP source?
6:28 pm on Sep 23, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Welcome aboard DrMopp! How does the data manifest itself on your site? If it's "included" in some way, such as via Javascript, SSI, or PHP, so that it becomes part of your documents, absolutely - you examine the source code for any object ID's or classes, or even elements, and apply CSS. Example:


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.

5:24 pm on Sep 27, 2008 (gmt 0)

5+ Year Member

Hi thx for reply. Sorry for delay but e-mail notification never arrived!

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)

6:54 pm on Sep 28, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

OK, so you are saying, an entire HTML page is generated <html> to </html> with the CSS in the head or in-line.

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":

.. external link to your css
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. :-) )

8:20 pm on Sep 29, 2008 (gmt 0)

5+ Year Member

But how would I use the output html as input to my asp/php/perl? I don't store it anywhere - it's just returned to the user when they click a link on my page. Wouldn't I need to fire off my asp/php and for that to include a call to 'their' asp? Sorry if I sound confused - I am!
10:23 pm on Sep 29, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

<a href="myscript.cgi">

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>,


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.

6:55 am on Sep 30, 2008 (gmt 0)

5+ Year Member

Thanks so much for this - will go and play now!

Featured Threads

Hot Threads This Week

Hot Threads This Month