开发者

How to verify html DIV's width and height on server side?

I was wondering if it's possible to verify a DIV's width and height on server side (PHP) without running any browser?

It seems it's not possible without writing a parser, which is no worth.

One Rube Goldberg way I could think of is, convert that DIV into html (using html tidy), then into PDF and then get the size. Highly inefficient. Even in that case I'm not sure how I'd set PDF page size.

Th开发者_运维技巧e real practical problem is that I want to confirm the size of adverts created on client side. Users are charged based on size only. What could be alternate ways to verify dimensions? Don't Google and adready (www.adready.com) do something like this already?

Edited: These ads are template based and customer changes only few TEXT variables.


It's definitely not possible. There is a plethora of client-side settings influencing the ways a page is rendered that you can't control. The only thing you could do is use a service like BrowserShots (http://browsershots.org) to make screenshots of what your sites look like in the most common browsers.

Edit: What you could do, on second thought, is write a JavaScript that determines the size of the elements - easy enough using a cross-browser framework like prototype using .getDimensions() - and send that data back to the server using Ajax. You would have to generate a unique id to identify the callcacks but this should be a good way. It seems a bit of an overkill to use this in a production environment but there are much more resource-consuming Javascripts built into sites every day.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜