anilsingh1605 Posted April 6, 2014 Share Posted April 6, 2014 I am building admin control panel for a website. The admin cp has 3 columns(div): 1st column/div - left menu items (left column) 2nd column/div - content display area (which is in center) 3rd column/div - right menu items (right column) This is how it works; when a link is clicked from 1st column/div, the page linked will be opened in the 2nd column/div and in the similar way when a link is clicked from 3rd column/div, the page linked will be opened in the 2nd column/div. I used iframe in 2nd column/div to achieve this i.e, open links in the same page without refreshing the page. The problem I have: When the page opened in 2nd column/div has the height greater than the height mentioned in the iframe, scroll bar appears inside the div. What I want: I want to display the linked page either from 1st column/div or 3rd column/div in 2nd column/div with its full height without the scroll bar appearing inside the div. The browser window (all columns combined) should get the scroll bar instead, using which I shall be able to scroll down. The left and right columns/div should go upwards/downwards when I use the scroll bar displaying the page linked/opened totally in 2nd column/div. ****In simple I want a facebook like design which should have menu items on either side of the browser window, clicking the links should open the page linked in center and if the linked page has more data that cannot be displayed in that div, it should expand the center div downwards to display the data (not dynamically, statically).**** Please get me this solved or suggest me another way to achieve this. Thanks in advance. admin.php styles.css view.php Quote Link to comment https://forums.phpfreaks.com/topic/287552-div-tags-help-needed-3-column-design/ Share on other sites More sharing options...
Ch0cu3r Posted April 6, 2014 Share Posted April 6, 2014 The problem is the iframe, once you set the height of the iframe it does not adapt the height of the content being loaded into it and so the scroll bars appear. However the use of iframes is no longer the trend. The trend now a days is ajax, this what facebook/google use to load their content dynamically onto the page. With ajax you can load content in the background and then dynamically add it the page seamlessly with the out the page refreshing. Quote Link to comment https://forums.phpfreaks.com/topic/287552-div-tags-help-needed-3-column-design/#findComment-1475102 Share on other sites More sharing options...
anilsingh1605 Posted April 6, 2014 Author Share Posted April 6, 2014 The problem is the iframe, once you set the height of the iframe it does not adapt the height of the content being loaded into it and so the scroll bars appear. However the use of iframes is no longer the trend. The trend now a days is ajax, this what facebook/google use to load their content dynamically onto the page. With ajax you can load content in the background and then dynamically add it the page seamlessly with the out the page refreshing. I too thought the same and used a different approach using include function and removing iframe but that hasn't solved the problem but created more problems. Can you modify the above attached files and use ajax as you say to achieve the same. That would be a great help for me. Quote Link to comment https://forums.phpfreaks.com/topic/287552-div-tags-help-needed-3-column-design/#findComment-1475115 Share on other sites More sharing options...
Ch0cu3r Posted April 6, 2014 Share Posted April 6, 2014 (edited) The very basics with JQuery will be adding the following in admin.php at the bottom of the page before the </body> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <!-- Link to the JQuery cdn, hosted by google --> <script type="text/javascript"> // on page load $(document).ready(function() { // add an onClick event to all links on the page $('a').click(function(e) { e.preventDefault(); // overrides default behaviour of links // get the target page from the href attribute of the link var target = $(this).attr('href'); // now load the target page using ajax $.ajax({ url: target, success: function(res) { $('div#content').html(res); // add the contents of the target page to the div with the id of content }, error: function(res) { alert(target + ' was not found'); // display error } }); return false; // prevent the link from working }); }); </script> Any link clicked, will load the contents of the page into the contents div without the page refreshing. JQuery ajax docs http://api.jquery.com/jQuery.ajax/ You can also apply some transition affects, such as making the content fadeIn/fadeOut when links are clicked etc. Edited April 6, 2014 by Ch0cu3r Quote Link to comment https://forums.phpfreaks.com/topic/287552-div-tags-help-needed-3-column-design/#findComment-1475122 Share on other sites More sharing options...
anilsingh1605 Posted April 6, 2014 Author Share Posted April 6, 2014 The very basics with JQuery will be adding the following in admin.php at the bottom of the page before the </body> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <!-- Link to the JQuery cdn, hosted by google --> <script type="text/javascript"> // on page load $(document).ready(function() { // add an onClick event to all links on the page $('a').click(function(e) { e.preventDefault(); // overrides default behaviour of links // get the target page from the href attribute of the link var target = $(this).attr('href'); // now load the target page using ajax $.ajax({ url: target, success: function(res) { $('div#content').html(res); // add the contents of the target page to the div with the id of content }, error: function(res) { alert(target + ' was not found'); // display error } }); return false; // prevent the link from working }); }); </script> Any link clicked, will load the contents of the page into the contents div without the page refreshing. JQuery ajax docs http://api.jquery.com/jQuery.ajax/ You can also apply some transition affects, such as making the content fadeIn/fadeOut when links are clicked etc. Thanks for the code. Will try the code and let you know. Quote Link to comment https://forums.phpfreaks.com/topic/287552-div-tags-help-needed-3-column-design/#findComment-1475125 Share on other sites More sharing options...
Ch0cu3r Posted April 6, 2014 Share Posted April 6, 2014 OH, I forgot to mention you need to replace the iframe with a div <div id="content"></div> Quote Link to comment https://forums.phpfreaks.com/topic/287552-div-tags-help-needed-3-column-design/#findComment-1475126 Share on other sites More sharing options...
anilsingh1605 Posted April 7, 2014 Author Share Posted April 7, 2014 The code worked. But now because of using that code I have two other problems. 1) After the page has been loaded in "content" div, and if the loaded page has link and when the link is clicked, the page gets refreshed and the linked page gets loaded. I want to open the link present in the "content" div in the same "content" div without refreshing the page. 2) After the page has been loaded in "content" div, and if the loaded page has submit button and when the submit button is clicked, the page gets refreshed and the action page gets loaded. I want to load the action page in the same "content" div that has the submit button without refreshing the page. In both the process, the basic 3 column design is getting effected. Kindly look at the screenshots I attached to grasp the issue. I even attached screens before clicking the link, after clicking the link and before clicking the submit and after clicking the submit. Eagerly waiting for your response. Quote Link to comment https://forums.phpfreaks.com/topic/287552-div-tags-help-needed-3-column-design/#findComment-1475279 Share on other sites More sharing options...
Ch0cu3r Posted April 7, 2014 Share Posted April 7, 2014 I will put hand up here and say I am out of my depth here. My JQuery knowledge is limited at best. However what you are doing is totally possible, but Im not the right person to direct you. Maybe someone else here will have a better insight into this. But what I do know is you are creating a Single Page Application. Which there are frameworks specifically designed to help you with this. You may want to check out AngularJS or similar. Quote Link to comment https://forums.phpfreaks.com/topic/287552-div-tags-help-needed-3-column-design/#findComment-1475295 Share on other sites More sharing options...
anilsingh1605 Posted April 8, 2014 Author Share Posted April 8, 2014 I will put hand up here and say I am out of my depth here. My JQuery knowledge is limited at best. However what you are doing is totally possible, but Im not the right person to direct you. Maybe someone else here will have a better insight into this. But what I do know is you are creating a Single Page Application. Which there are frameworks specifically designed to help you with this. You may want to check out AngularJS or similar. Yep. And it seems none of the users here are interested to answer this. Seems like I have to follow some other route to get this done. Quote Link to comment https://forums.phpfreaks.com/topic/287552-div-tags-help-needed-3-column-design/#findComment-1475381 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.