A few days ago, a foreign enterprise website was launched to meet the needs of friends;
I wanted to do it, but I didn't think that after I worked so hard to develop the php platform, the other party said that I cannot install other programs on the server. Please use the frame framework for development.
Lang Feng is a tough term. Then I tried to load a simple ifame page. It has a fatal feature: it cannot be automatically adjusted with the height of the content, cool people make some js judgments to achieve high adjustment.
This is not my style, it must be a more concise method, and it is also my favorite.
After thinking about it, I found: Isn't it the same as tabdiv switching?
Afterwards, I recalled the jquery plug-in made by a large e-commerce company: the content of the div sandbox was remotely loaded and switched randomly.
The plug-in requires a lot of judgment. In contrast, this ifame function is much simpler: click the button to automatically pull the page from the server and put it in the corresponding div, our powerful web browser will render the content perfectly.
It was a little late, and it was so fast that I immediately found the jquery. js to be used to load the page.
Then use the mature jquery development experience of longwind to quickly write
Then quickly add the class = cmenu attribute to any parent of the corresponding a tag. Run browser debugging. Hey hey, it's successful. It's really good. For the first time, I felt like this was actually amazing.
This Code seems simple (four lines of code are self-written, and six lines of code are added in jquery format), but its functions are unambiguous.
First, let's share it with you:
1. Restrict the function area to the parent node of class = cmenu to prevent the label from being infected in other places from affecting the normal function. This is a good thing for a gentleman, although php is developed with ape, we need to be a bit elegant.
2. The live function is bound to the tag to be operated in real time to prevent the newly loaded page from repeatedly using the code function we designed, the code that cannot be reused is not a good code.
3. Here, we use the load function to load the content of the server linked to the tag and fill it into the page for re-rendering. Gong Yuan said that I have a crush on you, and his mother said that we have a crush on us, it is such a perfect display.
4. "return false;" is also a key part of JavaScript, which invalidates the normal a link function. This operation can prevent problems caused by multiple a links and js Code: for example, the page is redirected to the header.