Link to home
Start Free TrialLog in
Avatar of Abdu_Allah
Abdu_Allah

asked on

Make a sligh change to the following code.

The following is a slide up window script(https://www.experts-exchange.com/questions/24284232/How-to-display-a-small-slide-popup-window.html), it works fine but I want to make a slight change so that I can be able to change the text that appears in that window while it's displayed (without closing it and re-displaying it.)

function SlideUP(options) {
    var mainWindow, mainWindowStyle;
    this.options = options;
    mainWindow = document.createElement('div');
    mainWindowStyle = mainWindow.style;
    mainWindowStyle.width = options.width + 'px';
    mainWindowStyle.height = options.height + 'px';
    mainWindowStyle.border = options.border;
    mainWindowStyle.background = options.background;
    mainWindowStyle.position = 'absolute';
    mainWindowStyle.visibility = 'hidden';
    document.body.appendChild(mainWindow);
    this.mainWindow = mainWindow;
}
 
SlideUP.prototype.show = function(text) {
    var self, mainWindow, mainWindowStyle, intervalGrow;
    self = this;
    mainWindow = this.mainWindow;
    mainWindow.innerHTML = '';
    mainWindowStyle = mainWindow.style;
    mainWindowStyle.left = (window.innerWidth || (document.documentElement.clientWidth || (document.body.clientWidth || 0))) -  this.options.width - 20 + 'px';
    mainWindowStyle.top = (window.innerHeight || (document.documentElement.clientHeight || (document.body.clientHeight || 0))) - 20 + 'px';
    mainWindowStyle.height = '0px';
    mainWindow.currentHeight = 0;
    mainWindowStyle.visibility = 'visible';
    intervalGrow = window.setInterval(function() {
        if(mainWindow.currentHeight < self.options.height) {
            mainWindowStyle.height = mainWindow.currentHeight + 'px';
            mainWindowStyle.top = parseInt(mainWindowStyle.top.split('px')[0], 10) - 4 + 'px';
            mainWindow.currentHeight+=4;
        }
        else {
            mainWindow.innerHTML = text;
            window.clearInterval(intervalGrow);
        }
    }, 10);
}
 
SlideUP.prototype.close = function() {
    this.mainWindow.style.visibility = 'hidden';
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of HonorGod
HonorGod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
So, is there anything else?
Avatar of Abdu_Allah
Abdu_Allah

ASKER

No, thanks.
You are welcome.  Thanks for the grade & points.

Morcalavin had an excellent suggestion though.

Good luck & have a great day.