views:

97

answers:

2

Hi,

I want to implement a utility for myself that should provide a small console where I can execute random JS in any browser (much like Firebug's console - I don't reinvent the wheel, I just want to do something I need and just have fun doing it).

So the usage use-case would be this:

  1. Click a bookmarklet from any browser.
  2. It shows dialog (much like jQuery dialog or similar) with text area and couple of buttons.
  3. User enter a JS in the text area.
  4. User clicks a button and it gets executed.
  5. User closes the dialog.

I don't know how I can display nice dialog on any web page (Gmail, news, static pages, whatever).

I think it would be possible to create a jQuery dialog (or other library) and show it on the page. But it could lead to a lot of issues as the dialog might conflict with page CSS, JS and so on.

So the question is how to display a custom dialog on any web page from all (major) browsers using JavaScript.

The NOTES: I don't want to have a popup window. IFRAME would be ok but we cannot use it as the web page's DOCTYPE might not support it.

Thanks,
Dmitriy.

A: 

bookmarklets are pieces of JS code, so you can basically develop any kind of JS program and use it via bookmarklet... just do what you would do normally. check how other bookmarklets work.

regarding the window display - use lightbox-like effect (DIV layered over other content).

dusoft
I know what bookmarlet is. The main question is the window. Yes, we can use DIV for sure, but how can you create the div without knowing the DOCTYPE, and generally having no knowledge about the content of the page? If you will add a DIV and try to attach a window to it - positioning of the window can be wrong because of other CSS applied on the page.
Dmytrii Nagirniak
what? what got DIV has to do with DOCTYPE? if you are not talking about HTML 2.0, there is DIV in all the latest versions.re CSS - you got javascript at your service, so just get screen/visible width and height and put it in the centre. use attribute `!imporant` to override original document CSS
dusoft
DIV has nothing to do with DCOTYPE, sure. Sorry for confusion: I meant to say that different rendering modes and different DOCTYPEs can affect where and how the DIV will appear. So it is hard to preserve the CSS of the dialog will be displayed on the page. So maybe there are other approaches known.
Dmytrii Nagirniak
ok, no problem. i am sure that you can use JS to get dimensions of the screen and position DIV via JS/CSS. lite-box functionality is what you should take care of. check:http://www.dolem.com/lytebox/how it positions the DIV/images and copy the necessary code from there.
dusoft
+1  A: 

http://getfirebug.com/lite.html

Works in IE, Opera, Safari - basically gives you firebug's functionality in any browser.

Erik
Dmytrii Nagirniak