in reply to Re: Parsing HTML code for formatting into JavaScript
in thread Parsing HTML code for formatting into JavaScript
It doesn't actually isolate the first <script> section but would instead parse everything passed to it. Btw, it would be called like so:sub html_to_js_var { my($vars) = shift; # Declare my @html = split(/\n/, $vars->{'html'}); my $var = $vars->{'js_var'}; my $in_quotes = $vars->{'in_quotes'}; # A value of either 'single' + or 'double' for ' or " respectively # Format foreach my $line (@html) { if ($in_quotes eq "single") { $line =~ s/\'/\\\'/g; $line =~ s/\</\<\'\+\'/g; } elsif ($in_quotes eq "double") { $line =~ s/\"/\\\"/g; $line =~ s/\</\<\"\+\"/g; } } return @html; }
What I am trying to do is display Google AdSense ads (or other ads) on my website and others, in a rotation with other ads. I know this is somehow possible (without violating Google's rules) b/c the PHP program OpenX ad server does it.my @js_code = html_to_js_var({ "html" => $html, "in_quotes" => "single" # Could be "double" });
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Parsing HTML code for formatting into JavaScript
by moritz (Cardinal) on Feb 10, 2009 at 17:05 UTC | |
by anxara (Initiate) on Feb 10, 2009 at 17:33 UTC |