Click here to Skip to main content
15,887,683 members
Home / Discussions / JavaScript
   

JavaScript

 
QuestionHow to send to another web page in a new tab? Pin
Member 1183686417-Jul-15 8:34
Member 1183686417-Jul-15 8:34 
AnswerRe: How to send to another web page in a new tab? Pin
Anil Vaghasiya19-Jul-15 19:47
professionalAnil Vaghasiya19-Jul-15 19:47 
Question<div>is not visible if window is minimized than 100% Pin
Member 1183819816-Jul-15 21:27
Member 1183819816-Jul-15 21:27 
QuestionRequire Book/Link Which Covers following topics Pin
Member 1184123815-Jul-15 22:55
Member 1184123815-Jul-15 22:55 
AnswerRe: Require Book/Link Which Covers following topics Pin
Anil Vaghasiya17-Jul-15 4:10
professionalAnil Vaghasiya17-Jul-15 4:10 
AnswerRe: Require Book/Link Which Covers following topics Pin
Member 1176120322-Jul-15 3:02
Member 1176120322-Jul-15 3:02 
QuestionElement flickers on scroll Pin
Member 1183819814-Jul-15 21:11
Member 1183819814-Jul-15 21:11 
AnswerRe: Element flickers on scroll Pin
jkirkerx15-Jul-15 8:47
professionaljkirkerx15-Jul-15 8:47 
You need a trigger loaded on DOM Ready, to fire a function
So when the viewport changes, the trigger fires a function that changes the position of the box in the upper right corner.

So there are several bindings here. It took me awhile to figure out how to handle multiple events.

$("#txt_ac_state") is a hidden textbox that holds the state of the box, if the box is a tab on the right, or fully displayed.

$("#div_adContainer") is your box.

build_adContainer is a function that creates my box dynamically on the fly.
It's a really long piece of code to post, so I just posted the basics mechanics of my thought.
[Edit] Whoops, I posted the first prototype, this was the final bind code.
$(document).ready(function () {

    viewportWidth = $(window).width(); viewportHeight = $(window).height; ac_state = 1;<br />
    initiateBinding();
    var $scrollingDiv = $("#div_adContainer");

    $(window).scroll(function () {
        $scrollingDiv
            .stop()
            .animate({
               "marginTop": ($(window).scrollTop())
            }, "fast");
    });

});

function initiateBinding() {<br />
    if (false === is_mobile_device()) {
        build_adContainer();
        window.addEventListener("resize", winResize);
        document.body.onresize = bodyResize;
    }
    else {
        build_adContainer_Moblie();
    }
}

function winResize(e) {
    viewportWidth = $(window).width(); viewportHeight = $(window).height;
    obj_width = 180; obj_height = 612; obj_start = viewportWidth + obj_width;
    ac_state = $("#txt_ac_state").val();
    if (ac_state === "1") {
        obj_x = viewportWidth - obj_width; obj_y = 150;
        $("#div_adContainer").css('left', obj_x + 'px');
    }
    else {
        obj_x = viewportWidth - 32; obj_y = 150;
        $("#div_adContainer").css('left', obj_x + 'px');
    }
    e.stopImmediatePropagation();
}

function bodyResize(e) {
    viewportWidth = $(window).width(); viewportHeight = $(window).height;
    obj_width = 180; obj_height = 612; obj_start = viewportWidth + obj_width;
    ac_state = $("#txt_ac_state").val();
    if (ac_state === "1") {        
        obj_x = viewportWidth - 32; obj_y = 150;
        $("#div_adContainer").css('left', obj_x + 'px');
    }
    else {
        obj_x = viewportWidth - obj_width; obj_y = 150;
        $("#div_adContainer").css('left', obj_x + 'px');
    }
}

The intention of the posted code samples is for you to get a better idea of how to move your box without flickering, and to detect changes that you have not anticipated yet.
Your going have to figure out it out on your own how to implement your new code, but just take it one step at a time.
GeneralRe: Element flickers on scroll Pin
Member 1183819815-Jul-15 23:57
Member 1183819815-Jul-15 23:57 
GeneralRe: Element flickers on scroll Pin
jkirkerx16-Jul-15 8:45
professionaljkirkerx16-Jul-15 8:45 
QuestionLoop through textboxes in table and perform validation clientside Pin
colliek14-Jul-15 10:13
colliek14-Jul-15 10:13 
AnswerRe: Loop through textboxes in table and perform validation clientside Pin
Anil Vaghasiya14-Jul-15 19:34
professionalAnil Vaghasiya14-Jul-15 19:34 
GeneralRe: Loop through textboxes in table and perform validation clientside Pin
colliek14-Jul-15 20:03
colliek14-Jul-15 20:03 
Questionfunctions Pin
Member 1183686414-Jul-15 5:52
Member 1183686414-Jul-15 5:52 
AnswerRe: functions Pin
Shmuel Zang14-Jul-15 18:46
Shmuel Zang14-Jul-15 18:46 
AnswerRe: functions Pin
Member 1184785019-Jul-15 12:31
Member 1184785019-Jul-15 12:31 
QuestionFile Upload doesn’t work on Mobiles Pin
Praveen Raghuvanshi13-Jul-15 6:57
professionalPraveen Raghuvanshi13-Jul-15 6:57 
QuestionBlob went away in IE 11? Pin
dbrenth10-Jul-15 10:06
dbrenth10-Jul-15 10:06 
Questionbrowser version detection window 7 machine and IE version 11 Pin
Member 118062861-Jul-15 5:39
Member 118062861-Jul-15 5:39 
AnswerRe: browser version detection window 7 machine and IE version 11 Pin
Richard Deeming1-Jul-15 7:52
mveRichard Deeming1-Jul-15 7:52 
Questionin MVC Edit page, how to check for null values? Pin
Member 1173386829-Jun-15 11:28
Member 1173386829-Jun-15 11:28 
AnswerRe: in MVC Edit page, how to check for null values? Pin
Richard Deeming30-Jun-15 1:22
mveRichard Deeming30-Jun-15 1:22 
GeneralRe: in MVC Edit page, how to check for null values? Pin
Member 1173386830-Jun-15 17:01
Member 1173386830-Jun-15 17:01 
GeneralRe: in MVC Edit page, how to check for null values? Pin
Afzaal Ahmad Zeeshan30-Jun-15 22:10
professionalAfzaal Ahmad Zeeshan30-Jun-15 22:10 
GeneralRe: in MVC Edit page, how to check for null values? Pin
Member 117338681-Jul-15 13:46
Member 117338681-Jul-15 13:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.