Automatic height chat iframe

Asked

Viewed 595 times

0

I’m developing a chat in php, it’s working perfectly, however, I’m having trouble putting the iframe for the main site where the client will have access, in the code it opens the iframe, but if I set a height (height) fixed or 100% for example, i cannot click on links or images that are below this iframe.

The code is this:

 <iframe id="iframe1" style="z-index:999999; background:none; right:0; width:400px; bottom:0; margin: 0;  position:fixed; padding: 0;" height=""  border="0" scrolling="no"  frameborder='0' src='link'></iframe> 

ex. it uses about 60px without the click, but when clicked it opens about 500px, how can I make it open a height proportional to closed or open?

1 answer

1

I don’t know if this is what you ask for, but I did it to be height: 60px; normal and after clicked stay height: 500px;

First I created an iframe: http://fiddle.jshell.net/peLr1adu/2/ and within it I created a button (and a script just to let us know that it was actually clicked).

<button id="click">Clique aqui!</button>

document.getElementById("click").onclick = function(){
    document.body.innerHTML = "Clicado!";
};

Then I used this iframe: http://fiddle.jshell.net/veba7wjg/4/ and a script for when the button is clicked, make the iframe bigger

<iframe id="chat" name="chat" sandbox="allow-scripts allow-same-origin" frameborder="0" src="//fiddle.jshell.net/peLr1adu/2/show/light"></iframe>

#chat {
  height: 60px;
  border: 1px solid black;
}
#chat.big {
  height: 500px;
}

window.frames["chat"].document.getElementById("click").onclick = function(){
  document.getElementById("chat").className = "big";
};

Sandbox attributes in iframe are not accurate if the chat is in the same domain as the site.

  • Hello, @Ricardo, that’s basically it, however, it has the java chat script already, here it works: https://hositec.com.br/hositecchats/ the problem is I get it pulled to another page without interfering with the elements that are below it, that for example, even closed (without being clicked) it gets 500px iframe space on top of site buttons, so I can’t click on anything from the site

  • The problem is that all iframe space is being used, even without having clicked to open the window

  • Can you put the chat on a page where it happens? On the page you passed seems to be working well for me. http://i.imgur.com/pFZPI1I.png - http://i.imgur.com/uYRL1uq.png

  • So, it works cool, the problem is that by putting a normal page with links and everything, the chat iframe covers the links understood? In other words, it is on top, even closed, it has a transparent background but uses the iframe space covering the other links of the site. it reserves 500px for example, the page is on my localhost. but suppose the site has a button just above the closed chat, I won’t be able to click it so

  • Without code or example with the bug, I can’t help much :/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.